Petr Horáček has posted comments on this change.

Change subject: net: introduce acquire module
......................................................................


Patch Set 16:

(3 comments)

https://gerrit.ovirt.org/#/c/60974/16/tests/network/ifacquire_test.py
File tests/network/ifacquire_test.py:

Line 69:     @mock.patch.object(ifacquire.ifcfg, 'ifdown')
Line 70:     @mock.patch.object(ifacquire, 'open', create=True)
Line 71:     def test_do_not_acquire_owned_nic(self, mock_open, mock_ifdown, 
mock_kill,
Line 72:                                       mock_flush):
Line 73:         with ifacquire.Transaction() as a:
> Hmm... yea even this is a bit ugly.
Done
Line 74:             a.prepare(ifaces=[NIC_NAME], netinfo_nets=NETINFO_NETS)
Line 75:             a.turn_down()
Line 76:             a.disable_onboot()
Line 77: 


Line 112:     def _test_acquire_ifcfg_nic(self, mock_isfile, mock_ifdown,
Line 113:                                 original_ifcfg,
Line 114:                                 ifcfg_after_turn_down,
Line 115:                                 ifcfg_after_disable_onboot):
Line 116:         with mock_ifacquire_opens() as (open_handle, 
atomic_write_handle):
> OK, I think I understand now... this with with made me dizzy.
Mock themselves or mock_ifacquire_opens context manager?
Line 117:             open_handle.readlines.return_value = original_ifcfg
Line 118:             atomic_write_handle.readlines.return_value = 
original_ifcfg
Line 119: 
Line 120:             with ifacquire.Transaction() as a:


Line 133: 
Line 134:     @mock.patch.object(ifacquire.ifcfg, 'ifdown', return_value=None)
Line 135:     @mock.patch.object(ifacquire.os.path, 'isfile', return_value=True)
Line 136:     def test_rollback_acquired_ifcfg_nic(self, mock_isfile, 
mock_ifdown):
Line 137:         with mock_ifacquire_opens() as (open_handle, 
atomic_write_handle):
> I guess here it is even easier to get rid of the context.
How?
Line 138:             open_handle.readlines.return_value = NIC_IFCFG
Line 139:             atomic_write_handle.readlines.return_value = NIC_IFCFG
Line 140: 
Line 141:             with self.assertRaises(TestException):


-- 
To view, visit https://gerrit.ovirt.org/60974
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I180cfd7d69c0ae0a24188bc3d909b9d3d7c12145
Gerrit-PatchSet: 16
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: Edward Haas <[email protected]>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Petr Horáček <[email protected]>
Gerrit-Reviewer: gerrit-hooks <[email protected]>
Gerrit-HasComments: Yes
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]

Reply via email to