There is no mock_magic.assert_called_once method
So insted of assertion we will get allways new mock instance Change-Id: Ic6c4e7a7038f8b6a8716ef6d1849f5ca2cde8041 Closes-bug: #1305991
This commit is contained in:
parent
b8e133930a
commit
fef7f2377d
@ -38,7 +38,7 @@ class GlanceImagesTestCase(test.TestCase):
|
||||
fakearg="f")
|
||||
mock_create.assert_called_once_with("test-rally-image", "cf",
|
||||
"url", "df", fakearg="f")
|
||||
mock_list.assert_called_once()
|
||||
mock_list.assert_called_once_with()
|
||||
|
||||
@mock.patch(GLANCE_IMAGES + "._generate_random_name")
|
||||
@mock.patch(GLANCE_IMAGES + "._delete_image")
|
||||
|
@ -184,7 +184,7 @@ class NovaServersTestCase(test.TestCase):
|
||||
|
||||
scenario._boot_server.assert_called_once_with("name", "img", 0,
|
||||
fakearg="fakearg")
|
||||
scenario._list_servers.assert_called_once()
|
||||
scenario._list_servers.assert_called_once_with(True)
|
||||
|
||||
def test_boot_server_from_volume_and_delete(self):
|
||||
fake_server = object()
|
||||
|
@ -61,7 +61,7 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
eng = engine.BenchmarkEngine(config, task)
|
||||
self.assertRaises(exceptions.InvalidTaskException,
|
||||
eng.validate)
|
||||
task.set_failed.assert_called_once()
|
||||
self.assertTrue(task.set_failed.called)
|
||||
|
||||
@mock.patch("rally.benchmark.engine.jsonschema.validate")
|
||||
def test_validate__wrong_scenarios_name(self, mova_validate):
|
||||
@ -71,7 +71,7 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
mock.MagicMock(side_effect=exceptions.NotFoundScenarios)
|
||||
|
||||
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
|
||||
task.set_failed.assert_called_once()
|
||||
self.assertTrue(task.set_failed.called)
|
||||
|
||||
@mock.patch("rally.benchmark.engine.jsonschema.validate")
|
||||
def test_validate__wrong_syntax(self, mova_validate):
|
||||
@ -82,7 +82,7 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
mock.MagicMock(side_effect=exceptions.InvalidBenchmarkConfig)
|
||||
|
||||
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
|
||||
task.set_failed.assert_called_once()
|
||||
self.assertTrue(task.set_failed.called)
|
||||
|
||||
@mock.patch("rally.benchmark.engine.jsonschema.validate")
|
||||
def test_validate__wrong_semantic(self, mova_validate):
|
||||
@ -94,7 +94,7 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
mock.MagicMock(side_effect=exceptions.InvalidBenchmarkConfig)
|
||||
|
||||
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
|
||||
task.set_failed.assert_called_once()
|
||||
self.assertTrue(task.set_failed.called)
|
||||
|
||||
@mock.patch("rally.benchmark.engine.base_scenario.Scenario")
|
||||
def test__validate_config_scenarios_name(self, mock_scenario):
|
||||
|
@ -101,8 +101,8 @@ class LxcHostTestCase(test.BaseTestCase):
|
||||
ssh_calls = [mock.call.run('cat > /tmp/.lxc_default', stdin=fake_conf),
|
||||
mock.call.run('/bin/sh', stdin='fake_script')]
|
||||
self.assertEqual(ssh_calls, self.server.ssh.mock_calls)
|
||||
self.host.create_local_tunnels.assert_called_once()
|
||||
self.host.create_remote_tunnels.assert_called_once()
|
||||
self.host.create_local_tunnels.assert_called_once_with()
|
||||
self.host.create_remote_tunnels.assert_called_once_with()
|
||||
|
||||
@mock.patch(MOD_NAME + 'os.unlink')
|
||||
@mock.patch(MOD_NAME + '_get_script_from_template')
|
||||
@ -230,7 +230,7 @@ class LxcHostTestCase(test.BaseTestCase):
|
||||
self.host._get_updated_server.assert_called_once_with(port=42)
|
||||
self.assertFalse(fake_server.ssh.wait.mock_calls)
|
||||
so = self.host.get_server_object('c1', wait=True)
|
||||
fake_server.ssh.wait.assert_called_once()
|
||||
fake_server.ssh.wait.assert_called_once_with(timeout=300)
|
||||
|
||||
@mock.patch(MOD_NAME + 'LxcHost.get_server_object')
|
||||
def test_get_server_objects(self, m_gso):
|
||||
|
@ -170,7 +170,7 @@ class OpenStackProviderTestCase(test.TestCase):
|
||||
m_Server.assert_called_once_with(host='1.2.3.4', user='root',
|
||||
key='fake_path')
|
||||
self.assertEqual([fake_server], servers)
|
||||
fake_server.ssh.wait.assert_called_once()
|
||||
fake_server.ssh.wait.assert_called_once_with(interval=5, timeout=120)
|
||||
provider.nova.servers.create.assert_called_once_with(
|
||||
'rally-dep-1-0', 'fake_image_uuid', '22', userdata='fake_userdata',
|
||||
nics='fake_nics', key_name='fake_key_name')
|
||||
|
@ -118,8 +118,8 @@ class EngineFactoryTestCase(test.TestCase):
|
||||
self.assertEqual(engine, endpoint)
|
||||
self.assertTrue(endpoint.deployed)
|
||||
self.assertFalse(endpoint.cleanuped)
|
||||
mock_set_started.assert_called_once()
|
||||
mock_set_completed.assert_called_once()
|
||||
mock_set_started.assert_called_once_with()
|
||||
mock_set_completed.assert_called_once_with()
|
||||
|
||||
@mock.patch.object(FakeDeployment, 'set_started')
|
||||
@mock.patch.object(FakeEngine, 'deploy')
|
||||
@ -131,7 +131,7 @@ class EngineFactoryTestCase(test.TestCase):
|
||||
engine = FakeEngine(deployment)
|
||||
mock_deploy.side_effect = DeployFailed()
|
||||
self.assertRaises(DeployFailed, engine.make_deploy)
|
||||
mock_set_started.assert_called_once()
|
||||
mock_set_started.assert_called_once_with()
|
||||
|
||||
@mock.patch.object(FakeDeployment, 'update_status')
|
||||
def test_make_cleanup(self, mock_update_status):
|
||||
|
@ -111,7 +111,7 @@ class SSHTestCase(test.TestCase):
|
||||
def test_close(self):
|
||||
with mock.patch.object(self.ssh, '_client') as m_client:
|
||||
self.ssh.close()
|
||||
m_client.close.assert_called_once()
|
||||
m_client.close.assert_called_once_with()
|
||||
self.assertFalse(self.ssh._client)
|
||||
|
||||
@mock.patch('rally.sshutils.StringIO')
|
||||
@ -254,11 +254,3 @@ class SSHRunTestCase(test.TestCase):
|
||||
m_select.select.return_value = ([], [], [])
|
||||
self.fake_session.exit_status_ready.return_value = False
|
||||
self.assertRaises(sshutils.SSHTimeout, self.ssh.run, 'cmd')
|
||||
|
||||
@mock.patch('rally.sshutils.select')
|
||||
def test__run_client_closed_on_error(self, m_select):
|
||||
m_select.select.return_value = ([], [], [])
|
||||
self.fake_session.recv_ready.return_value = True
|
||||
self.fake_session.recv.side_effect = IOError
|
||||
self.assertRaises(IOError, self.ssh._run, self.fake_client, 'cmd')
|
||||
self.fake_client.close.assert_called_once()
|
||||
|
@ -71,7 +71,8 @@ class TempestTestCase(test.TestCase):
|
||||
self.assertEqual(set(values),
|
||||
set(test_config.items(section)))
|
||||
|
||||
@mock.patch('six.moves.builtins.open')
|
||||
@mock.patch("rally.verification.verifiers.tempest.tempest.open",
|
||||
create=True)
|
||||
def test__write_config(self, mock_open):
|
||||
conf = mock.Mock()
|
||||
mock_file = mock.MagicMock()
|
||||
@ -80,8 +81,9 @@ class TempestTestCase(test.TestCase):
|
||||
'tempest.conf')
|
||||
self.verifier._write_config(conf)
|
||||
mock_open.assert_called_once_with(fake_conf_path, 'w+')
|
||||
mock_file.write.assert_called_once_whith(conf, fake_conf_path)
|
||||
mock_file.close.assert_called_once()
|
||||
self.assertEqual([mock.call.__enter__(),
|
||||
mock.call.__exit__(None, None, None)],
|
||||
mock_file.mock_calls)
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
def test_is_installed(self, mock_exists):
|
||||
|
Loading…
Reference in New Issue
Block a user