Merge "Set any_order to True in some unit tests"

This commit is contained in:
Jenkins 2014-07-22 15:34:04 +00:00 committed by Gerrit Code Review
commit de68be5120
3 changed files with 31 additions and 36 deletions

View File

@ -132,9 +132,11 @@ class ContextManagerTestCase(test.TestCase):
mock_get.assert_has_calls([
mock.call("a"),
mock.call("b"),
], any_order=True)
mock_get.assert_has_calls([
mock.call()(context),
mock.call()(context)
])
mock.call()(context),
], any_order=True)
@mock.patch("rally.benchmark.context.base.Context.get_by_name")
def test_validate(self, mock_get):
@ -144,12 +146,11 @@ class ContextManagerTestCase(test.TestCase):
}
base.ContextManager.validate(config)
mock_get.assert_has_calls([
mock.call("ctx1"),
mock.call().validate(config["ctx1"], non_hidden=False),
mock.call("ctx2"),
mock.call().validate(config["ctx2"], non_hidden=False)
])
for ctx in ("ctx1", "ctx2"):
mock_get.assert_has_calls([
mock.call(ctx),
mock.call().validate(config[ctx], non_hidden=False),
])
@mock.patch("rally.benchmark.context.base.Context.get_by_name")
def test_validate_semantic(self, mock_get):
@ -159,14 +160,12 @@ class ContextManagerTestCase(test.TestCase):
}
base.ContextManager.validate_semantic(config)
mock_get.assert_has_calls([
mock.call("ctx1"),
mock.call().validate_semantic(config["ctx1"], admin=None,
users=None, task=None),
mock.call("ctx2"),
mock.call().validate_semantic(config["ctx2"], admin=None,
users=None, task=None)
])
for ctx in ("ctx1", "ctx2"):
mock_get.assert_has_calls([
mock.call(ctx),
mock.call().validate_semantic(config[ctx], admin=None,
users=None, task=None),
])
@mock.patch("rally.benchmark.context.base.Context.get_by_name")
def test_validate_non_hidden(self, mock_get):
@ -176,12 +175,11 @@ class ContextManagerTestCase(test.TestCase):
}
base.ContextManager.validate(config, non_hidden=True)
mock_get.assert_has_calls([
mock.call("ctx1"),
mock.call().validate(config["ctx1"], non_hidden=True),
mock.call("ctx2"),
mock.call().validate(config["ctx2"], non_hidden=True)
])
for ctx in ("ctx1", "ctx2"):
mock_get.assert_has_calls([
mock.call(ctx),
mock.call().validate(config[ctx], non_hidden=True),
])
def test_validate__non_existing_context(self):
config = {

View File

@ -23,16 +23,11 @@ from tests import test
class RoleGeneratorTestCase(test.TestCase):
def create_default_roles_and_patch_add_remove_fuinctions(self, fc):
def create_default_roles_and_patch_add_remove_functions(self, fc):
fc.keystone().roles.add_user_role = mock.MagicMock()
fc.keystone().roles.remove_user_role = mock.MagicMock()
self.assertEqual(0, len(fc.keystone().roles.list()))
default_roles = [{"id": "r1", "name": "test_role1"},
{"id": "r2", "name": "test_role2"}]
fc.keystone().roles.create(*default_roles[0].values())
fc.keystone().roles.create(*default_roles[1].values())
fc.keystone().roles.create("r1", "test_role1")
fc.keystone().roles.create("r2", "test_role2")
self.assertEqual(2, len(fc.keystone().roles.list()))
@property
@ -52,7 +47,7 @@ class RoleGeneratorTestCase(test.TestCase):
def test_add_role(self, mock_osclients):
fc = fakes.FakeClients()
mock_osclients.Clients.return_value = fc
self.create_default_roles_and_patch_add_remove_fuinctions(fc)
self.create_default_roles_and_patch_add_remove_functions(fc)
ctx = roles.RoleGenerator(self.context)
ctx.context["users"] = [{"id": "u1", "tenant_id": "t1"},
@ -67,7 +62,7 @@ class RoleGeneratorTestCase(test.TestCase):
def test_add_role_which_does_not_exist(self, mock_osclients):
fc = fakes.FakeClients()
mock_osclients.Clients.return_value = fc
self.create_default_roles_and_patch_add_remove_fuinctions(fc)
self.create_default_roles_and_patch_add_remove_functions(fc)
ctx = roles.RoleGenerator(self.context)
ctx.context["users"] = [{"id": "u1", "tenant_id": "t1"},
@ -96,7 +91,7 @@ class RoleGeneratorTestCase(test.TestCase):
def test_setup_and_cleanup(self, mock_osclients):
fc = fakes.FakeClients()
mock_osclients.Clients.return_value = fc
self.create_default_roles_and_patch_add_remove_fuinctions(fc)
self.create_default_roles_and_patch_add_remove_functions(fc)
with roles.RoleGenerator(self.context) as ctx:
ctx.context["users"] = [{"id": "u1", "tenant_id": "t1"},

View File

@ -126,9 +126,11 @@ class BenchmarkEngineTestCase(test.TestCase):
config = {"sca": [{"context": "a"}], "scb": [{"runner": "b"}]}
eng = engine.BenchmarkEngine(mock.MagicMock(), mock.MagicMock())
eng._validate_config_syntax(config)
mock_runner.assert_has_calls([mock.call({}), mock.call("b")])
mock_runner.assert_has_calls([mock.call({}), mock.call("b")],
any_order=True)
mock_context.assert_has_calls([mock.call("a", non_hidden=True),
mock.call({}, non_hidden=True)])
mock.call({}, non_hidden=True)],
any_order=True)
@mock.patch("rally.benchmark.engine.base_runner.ScenarioRunner")
@mock.patch("rally.benchmark.engine.base_ctx.ContextManager.validate")
@ -218,7 +220,7 @@ class BenchmarkEngineTestCase(test.TestCase):
mock.call(admin, user, "a", 1, fake_task, config["a"][1]),
mock.call(admin, user, "b", 0, fake_task, config["b"][0])
]
mock_helper.assert_has_calls(expected_calls)
mock_helper.assert_has_calls(expected_calls, any_order=True)
@mock.patch("rally.benchmark.engine.BenchmarkEngine.consume_results")
def test_run__update_status(self, mock_consume):