Change in vdsm[master]: test: Use mock module for testing

nsoffer at redhat.com nsoffer at redhat.com
Tue Mar 29 16:33:44 UTC 2016


Nir Soffer has posted comments on this change.

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


Patch Set 3:

(4 comments)

https://gerrit.ovirt.org/#/c/55342/3/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):
What is mock_switch and the other parameters?

These parameters will likely to clash with py.test, which uses test parameters for injecting stuff like tmpdir and monkeypatch.
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
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__()
Why do you need to call __enter__(), and where the call to __exit__()?
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 60:         mock_configurator = mock_switch.ConfiguratorClass().__enter__()
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)
What if this was called several times? which call are you asserting - the first? last?
Line 65:         mock_switch.bonds_setup.assert_called_with(self.BOND_TEST,
Line 66:                                                    mock_configurator,
Line 67:                                                    None,
Line 68:                                                    False)


Line 64:                                                        None, None)
Line 65:         mock_switch.bonds_setup.assert_called_with(self.BOND_TEST,
Line 66:                                                    mock_configurator,
Line 67:                                                    None,
Line 68:                                                    False)
Can you check the order of the calls? does it matter?
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)


-- 
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: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Edward Haas <edwardh at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Edward Haas <edwardh at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Ondřej Svoboda <osvoboda at redhat.com>
Gerrit-Reviewer: Petr Horáček <phoracek at redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list