Nir Soffer has posted comments on this change.

Change subject: test: Use mock module for testing
......................................................................


Patch Set 6: Code-Review-1

(4 comments)

https://gerrit.ovirt.org/#/c/55342/6/tests/network/netswitch_test.py
File tests/network/netswitch_test.py:

Line 47:     @mock.patch('vdsm.network.netswitch.libvirtNets2vdsm')
Line 48:     @mock.patch('vdsm.network.netswitch.libvirt_nets')
Line 49:     @mock.patch('vdsm.network.netswitch.legacy_switch')
Line 50:     def test_setup(self, mock_switch, mock_libvirt_nets, 
mock_libvirtNets2vdsm,
Line 51:                    mock_netinfo_get, mock_CachingNetInfo, 
mock_connectivity):
Can you run this test with py.test?

I think it wil clash with py.test funcargs.
Line 52: 
Line 53:         mock_libvirt_nets.return_value = None
Line 54:         mock_libvirtNets2vdsm.return_value = None
Line 55:         mock_netinfo_get.return_value = None


Line 52: 
Line 53:         mock_libvirt_nets.return_value = None
Line 54:         mock_libvirtNets2vdsm.return_value = None
Line 55:         mock_netinfo_get.return_value = None
Line 56:         mock_CachingNetInfo.return_value = None
There is lot of boilerplate here, which you will have to repeat for each test.
Line 57: 
Line 58:         netswitch.setup(self.NET_TEST, self.BOND_TEST, self.OPT_TEST, 
False)
Line 59: 
Line 60:         mock_configurator = mock_switch.ConfiguratorClass().__enter__()


Line 56:         mock_CachingNetInfo.return_value = None
Line 57: 
Line 58:         netswitch.setup(self.NET_TEST, self.BOND_TEST, self.OPT_TEST, 
False)
Line 59: 
Line 60:         mock_configurator = mock_switch.ConfiguratorClass().__enter__()
This is still not clear.
Line 61:         mock_switch.remove_networks.assert_called_with(self.NET_TEST,
Line 62:                                                        self.BOND_TEST,
Line 63:                                                        
mock_configurator,
Line 64:                                                        None, None)


Line 69:         
mock_switch.add_missing_networks.assert_called_with(mock_configurator,
Line 70:                                                             
self.NET_TEST,
Line 71:                                                             
self.BOND_TEST,
Line 72:                                                             None)
Line 73:         mock_connectivity.check.assert_called_with(self.OPT_TEST)
You are not asserting anything about the order of the calls.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I1c0af7baab7c35a2617bd60a62a0b1534e5f8894
Gerrit-PatchSet: 6
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Edward Haas <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: Edward Haas <[email protected]>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <[email protected]>
Gerrit-Reviewer: Ondřej Svoboda <[email protected]>
Gerrit-Reviewer: Petr Horáček <[email protected]>
Gerrit-Reviewer: Piotr Kliczewski <[email protected]>
Gerrit-Reviewer: Sandro Bonazzola <[email protected]>
Gerrit-Reviewer: Yaniv Bronhaim <[email protected]>
Gerrit-Reviewer: gerrit-hooks <[email protected]>
Gerrit-HasComments: Yes
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to