Merge "fixes tests using called_once_ without assert"
This commit is contained in:
commit
e172d6be27
@ -244,7 +244,7 @@ class TestAsyncProcess(base.BaseTestCase):
|
|||||||
self.proc._kill_event = True
|
self.proc._kill_event = True
|
||||||
with mock.patch.object(self.proc, '_kill') as mock_kill:
|
with mock.patch.object(self.proc, '_kill') as mock_kill:
|
||||||
self.proc.stop()
|
self.proc.stop()
|
||||||
mock_kill.called_once()
|
mock_kill.assert_called_once_with()
|
||||||
|
|
||||||
def test_stop_raises_exception_if_already_started(self):
|
def test_stop_raises_exception_if_already_started(self):
|
||||||
with testtools.ExpectedException(async_process.AsyncProcessException):
|
with testtools.ExpectedException(async_process.AsyncProcessException):
|
||||||
|
@ -700,7 +700,7 @@ class TestOvsNeutronAgent(base.BaseTestCase):
|
|||||||
self.agent.daemon_loop()
|
self.agent.daemon_loop()
|
||||||
mock_get_pm.assert_called_with(True, 'sudo',
|
mock_get_pm.assert_called_with(True, 'sudo',
|
||||||
constants.DEFAULT_OVSDBMON_RESPAWN)
|
constants.DEFAULT_OVSDBMON_RESPAWN)
|
||||||
mock_loop.called_once()
|
mock_loop.assert_called_once_with(polling_manager=mock.ANY)
|
||||||
|
|
||||||
def test_setup_tunnel_port_error_negative(self):
|
def test_setup_tunnel_port_error_negative(self):
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
|
@ -181,5 +181,5 @@ class TestCli(base.BaseTestCase):
|
|||||||
mock_open.return_value.__exit__ = mock.Mock()
|
mock_open.return_value.__exit__ = mock.Mock()
|
||||||
|
|
||||||
cli.update_head_file(mock.sentinel.config)
|
cli.update_head_file(mock.sentinel.config)
|
||||||
mock_open.write.called_once_with('a')
|
mock_open.return_value.write.assert_called_once_with('a')
|
||||||
fc.assert_called_once_with(mock.sentinel.config)
|
fc.assert_called_once_with(mock.sentinel.config)
|
||||||
|
@ -718,7 +718,7 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
|
|||||||
self.plugin.get_network_info.return_value = network
|
self.plugin.get_network_info.return_value = network
|
||||||
with mock.patch.object(self.dhcp, 'disable_dhcp_helper') as disable:
|
with mock.patch.object(self.dhcp, 'disable_dhcp_helper') as disable:
|
||||||
self.dhcp.refresh_dhcp_helper(network.id)
|
self.dhcp.refresh_dhcp_helper(network.id)
|
||||||
disable.called_once_with_args(network.id)
|
disable.assert_called_once_with(network.id)
|
||||||
self.assertFalse(self.cache.called)
|
self.assertFalse(self.cache.called)
|
||||||
self.assertFalse(self.call_driver.called)
|
self.assertFalse(self.call_driver.called)
|
||||||
self.cache.assert_has_calls(
|
self.cache.assert_has_calls(
|
||||||
@ -1299,14 +1299,14 @@ class TestDeviceManager(base.BaseTestCase):
|
|||||||
expected = ('dhcp1ae5f96c-c527-5079-82ea-371a01645457-12345678-1234-'
|
expected = ('dhcp1ae5f96c-c527-5079-82ea-371a01645457-12345678-1234-'
|
||||||
'5678-1234567890ab')
|
'5678-1234567890ab')
|
||||||
|
|
||||||
with mock.patch('socket.gethostbyname') as get_host:
|
with mock.patch('socket.gethostname') as get_host:
|
||||||
with mock.patch('uuid.uuid5') as uuid5:
|
with mock.patch('uuid.uuid5') as uuid5:
|
||||||
uuid5.return_value = '1ae5f96c-c527-5079-82ea-371a01645457'
|
uuid5.return_value = '1ae5f96c-c527-5079-82ea-371a01645457'
|
||||||
get_host.return_value = 'localhost'
|
get_host.return_value = 'localhost'
|
||||||
|
|
||||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
||||||
uuid5.called_once_with(uuid.NAMESPACE_DNS, 'localhost')
|
|
||||||
self.assertEqual(dh.get_device_id(fake_net), expected)
|
self.assertEqual(dh.get_device_id(fake_net), expected)
|
||||||
|
uuid5.assert_called_once_with(uuid.NAMESPACE_DNS, 'localhost')
|
||||||
|
|
||||||
def _get_device_manager_with_mock_device(self, conf, device):
|
def _get_device_manager_with_mock_device(self, conf, device):
|
||||||
dh = dhcp.DeviceManager(conf, cfg.CONF.root_helper, None)
|
dh = dhcp.DeviceManager(conf, cfg.CONF.root_helper, None)
|
||||||
|
@ -319,12 +319,12 @@ class TestUnixDomainWSGIServer(base.BaseTestCase):
|
|||||||
with mock.patch.object(agent, 'logging') as logging:
|
with mock.patch.object(agent, 'logging') as logging:
|
||||||
self.server._run('app', 'sock')
|
self.server._run('app', 'sock')
|
||||||
|
|
||||||
self.eventlet.wsgi.server.called_once_with(
|
self.eventlet.wsgi.server.assert_called_once_with(
|
||||||
'sock',
|
'sock',
|
||||||
'app',
|
'app',
|
||||||
self.server.pool,
|
protocol=agent.UnixDomainHttpProtocol,
|
||||||
agent.UnixDomainHttpProtocol,
|
log=mock.ANY,
|
||||||
mock.ANY
|
custom_pool=self.server.pool
|
||||||
)
|
)
|
||||||
self.assertTrue(len(logging.mock_calls))
|
self.assertTrue(len(logging.mock_calls))
|
||||||
|
|
||||||
|
@ -38,8 +38,10 @@ class TestTesttoolsExceptionHandler(base.BaseTestCase):
|
|||||||
return_value=mock.Mock()):
|
return_value=mock.Mock()):
|
||||||
post_mortem_debug.exception_handler(exc_info)
|
post_mortem_debug.exception_handler(exc_info)
|
||||||
|
|
||||||
mock_print_exception.called_once_with(*exc_info)
|
# traceback will become post_mortem_debug.FilteredTraceback
|
||||||
mock_post_mortem.called_once()
|
filtered_exc_info = (exc_info[0], exc_info[1], mock.ANY)
|
||||||
|
mock_print_exception.assert_called_once_with(*filtered_exc_info)
|
||||||
|
mock_post_mortem.assert_called_once_with(mock.ANY)
|
||||||
|
|
||||||
|
|
||||||
class TestFilteredTraceback(base.BaseTestCase):
|
class TestFilteredTraceback(base.BaseTestCase):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user