Exemplo n.º 1
0
    def test_kill_dhcp(self, dhcp_active=True):
        conf = mock.Mock()
        conf.AGENT.root_helper = 'sudo',
        conf.dhcp_driver = 'driver'

        method_to_patch = 'oslo.utils.importutils.import_object'

        with mock.patch(method_to_patch) as import_object:
            driver = mock.Mock()
            driver.active = dhcp_active
            import_object.return_value = driver

            util.kill_dhcp(conf, 'ns')

            expected_params = {
                'conf': conf,
                'network': mock.ANY,
                'root_helper': conf.AGENT.root_helper,
                'plugin': mock.ANY
            }
            import_object.assert_called_once_with('driver', **expected_params)

            if dhcp_active:
                driver.assert_has_calls([mock.call.disable()])
            else:
                self.assertFalse(driver.called)
Exemplo n.º 2
0
    def test_kill_dhcp(self, dhcp_active=True):
        conf = mock.Mock()
        conf.AGENT.root_helper = 'sudo',
        conf.dhcp_driver = 'driver'

        method_to_patch = 'neutron.openstack.common.importutils.import_object'

        with mock.patch(method_to_patch) as import_object:
            driver = mock.Mock()
            driver.active = dhcp_active
            import_object.return_value = driver

            util.kill_dhcp(conf, 'ns')

            import_object.called_once_with('driver', conf, mock.ANY,
                                           conf.AGENT.root_helper, mock.ANY)

            if dhcp_active:
                driver.assert_has_calls([mock.call.disable()])
            else:
                self.assertFalse(driver.called)
Exemplo n.º 3
0
    def test_kill_dhcp(self, dhcp_active=True):
        conf = mock.Mock()
        conf.AGENT.root_helper = 'sudo',
        conf.dhcp_driver = 'driver'

        method_to_patch = 'neutron.openstack.common.importutils.import_object'

        with mock.patch(method_to_patch) as import_object:
            driver = mock.Mock()
            driver.active = dhcp_active
            import_object.return_value = driver

            util.kill_dhcp(conf, 'ns')

            import_object.called_once_with('driver', conf, mock.ANY,
                                           conf.AGENT.root_helper, mock.ANY)

            if dhcp_active:
                driver.assert_has_calls([mock.call.disable()])
            else:
                self.assertFalse(driver.called)
    def test_kill_dhcp(self, dhcp_active=True):
        conf = mock.Mock()
        conf.AGENT.root_helper = 'sudo',
        conf.dhcp_driver = 'driver'

        method_to_patch = 'oslo.utils.importutils.import_object'

        with mock.patch(method_to_patch) as import_object:
            driver = mock.Mock()
            driver.active = dhcp_active
            import_object.return_value = driver

            util.kill_dhcp(conf, 'ns')

            expected_params = {'conf': conf, 'network': mock.ANY,
                               'root_helper': conf.AGENT.root_helper,
                               'plugin': mock.ANY}
            import_object.assert_called_once_with('driver', **expected_params)

            if dhcp_active:
                driver.assert_has_calls([mock.call.disable()])
            else:
                self.assertFalse(driver.called)