Fixed order of arguments in assertEqual

Some tests used incorrect order of arguments in
assertEqual(observed, expected). The correct order expected
by testtool is assertEqual(expected, observed).

Partial-Bug: #1259292

Change-Id: I944b72f743a21d0908d17485c25aeb0e7ee70cba
changes/82/444582/18
sudhir_agarwal 5 years ago committed by Boris Pavlovic
parent d15d2c89e7
commit 0aec3cc166
  1. 4
      tests/functional/test_cli_task.py
  2. 6
      tests/unit/cli/commands/test_plugin.py
  3. 8
      tests/unit/cli/commands/test_task.py
  4. 16
      tests/unit/cli/test_cliutils.py
  5. 8
      tests/unit/cli/test_envutils.py
  6. 132
      tests/unit/common/db/test_api.py
  7. 126
      tests/unit/common/db/test_migrations.py
  8. 14
      tests/unit/common/objects/test_deploy.py
  9. 4
      tests/unit/common/plugin/test_meta.py
  10. 8
      tests/unit/common/plugin/test_plugin.py
  11. 16
      tests/unit/common/test_logging.py
  12. 4
      tests/unit/common/test_sshutils.py
  13. 48
      tests/unit/common/test_utils.py
  14. 16
      tests/unit/plugins/common/runners/test_constant.py
  15. 4
      tests/unit/plugins/common/runners/test_rps.py
  16. 6
      tests/unit/plugins/common/runners/test_serial.py
  17. 4
      tests/unit/plugins/common/test_types.py
  18. 6
      tests/unit/plugins/openstack/cleanup/test_base.py
  19. 6
      tests/unit/plugins/openstack/cleanup/test_manager.py
  20. 24
      tests/unit/plugins/openstack/context/keystone/test_users.py
  21. 2
      tests/unit/plugins/openstack/context/manila/test_manila_security_services.py
  22. 18
      tests/unit/plugins/openstack/context/network/test_network.py
  23. 4
      tests/unit/plugins/openstack/context/nova/test_flavors.py
  24. 12
      tests/unit/plugins/openstack/scenarios/cinder/test_utils.py
  25. 32
      tests/unit/plugins/openstack/scenarios/neutron/test_utils.py
  26. 12
      tests/unit/plugins/openstack/services/storage/test_cinder_common.py
  27. 28
      tests/unit/plugins/openstack/test_types.py
  28. 22
      tests/unit/plugins/openstack/test_validators.py
  29. 24
      tests/unit/plugins/openstack/verification/tempest/test_config.py
  30. 16
      tests/unit/plugins/openstack/verification/tempest/test_context.py
  31. 80
      tests/unit/plugins/openstack/wrappers/test_network.py
  32. 4
      tests/unit/task/processing/test_plot.py
  33. 6
      tests/unit/task/test_atomic.py
  34. 14
      tests/unit/task/test_context.py
  35. 2
      tests/unit/task/test_engine.py
  36. 6
      tests/unit/task/test_runner.py
  37. 2
      tests/unit/task/test_scenario.py
  38. 12
      tests/unit/task/test_utils.py
  39. 2
      tests/unit/task/test_validation.py
  40. 13
      tests/unit/test_hacking.py
  41. 6
      tests/unit/test_osclients.py
  42. 11
      tests/unit/test_test_ddt.py

@ -1074,7 +1074,7 @@ class SLAExtraFlagsTestCase(unittest.TestCase):
try:
rally("task sla-check --json", getjson=True)
except utils.RallyCliError as expected_error:
self.assertEqual(json.loads(expected_error.output), expected)
self.assertEqual(expected, json.loads(expected_error.output))
else:
self.fail("`rally task sla-check` command should return non-zero "
"exit code")
@ -1102,7 +1102,7 @@ class SLAExtraFlagsTestCase(unittest.TestCase):
try:
rally("task sla-check --json", getjson=True)
except utils.RallyCliError as expected_error:
self.assertEqual(json.loads(expected_error.output), expected)
self.assertEqual(expected, json.loads(expected_error.output))
else:
self.fail("`rally task sla-check` command should return non-zero "
"exit code")

@ -112,7 +112,7 @@ class PluginCommandsTestCase(test.TestCase):
def test_show_not_found(self, name, namespace, text):
with utils.StdOutCapture() as out:
plugin_cmd.PluginCommands().show(None, name, namespace)
self.assertEqual(out.getvalue(), text)
self.assertEqual(text, out.getvalue())
@mock.patch("rally.cli.commands.plugin.PluginCommands._print_plugins_list")
def test_show_many(self, mock_plugin_commands__print_plugins_list):
@ -121,7 +121,7 @@ class PluginCommandsTestCase(test.TestCase):
"get_all") as mock_plugin_get_all:
mock_plugin_get_all.return_value = [self.Plugin2, self.Plugin3]
plugin_cmd.PluginCommands().show(None, "p", "p2_ns")
self.assertEqual(out.getvalue(), "Multiple plugins found:\n")
self.assertEqual("Multiple plugins found:\n", out.getvalue())
mock_plugin_get_all.assert_called_once_with(platform="p2_ns")
mock_plugin_commands__print_plugins_list.assert_called_once_with([
@ -144,7 +144,7 @@ class PluginCommandsTestCase(test.TestCase):
with utils.StdOutCapture() as out:
plugin_cmd.PluginCommands().list(None, name, namespace)
self.assertEqual(out.getvalue(), text)
self.assertEqual(text, out.getvalue())
@mock.patch("rally.cli.commands.plugin.PluginCommands._print_plugins_list")
def test_list(self, mock_plugin_commands__print_plugins_list):

@ -61,7 +61,7 @@ class TaskCommandsTestCase(test.TestCase):
]
task_conf = self.task._load_and_validate_task(
self.real_api, "in_task", raw_args=input_args)
self.assertEqual(task_conf, {"ab": 2})
self.assertEqual({"ab": 2}, task_conf)
mock_open.side_effect = [
mock.mock_open(read_data=input_task).return_value,
@ -70,7 +70,7 @@ class TaskCommandsTestCase(test.TestCase):
task_conf = self.task._load_and_validate_task(
self.real_api, "in_task", raw_args=input_args,
args_file="any_file")
self.assertEqual(task_conf, {"ab": 2})
self.assertEqual({"ab": 2}, task_conf)
mock_open.side_effect = [
mock.mock_open(read_data=input_task).return_value,
@ -79,7 +79,7 @@ class TaskCommandsTestCase(test.TestCase):
task_conf = self.task._load_and_validate_task(
self.real_api, "in_task", raw_args="test=2",
args_file="any_file")
self.assertEqual(task_conf, {"ab": 2})
self.assertEqual({"ab": 2}, task_conf)
@mock.patch("rally.cli.commands.task.open", create=True)
def test__load_task_wrong_task_args_file(self, mock_open):
@ -740,7 +740,7 @@ class TaskCommandsTestCase(test.TestCase):
def test_old_report_exceptions(self, mock_open, mock_path_exists):
ret = self.task._old_report(self.real_api, tasks="/tmp/task.json",
out="/tmp/tmp.hsml")
self.assertEqual(ret, 1)
self.assertEqual(1, ret)
@mock.patch("rally.cli.commands.task.os.path.exists", return_value=True)
def test_report(self, mock_path_exists):

@ -149,7 +149,7 @@ class CliUtilsTestCase(test.TestCase):
def test_make_header(self):
h1 = cliutils.make_header("msg", size=4, symbol="=")
self.assertEqual(h1, "====\nmsg\n====\n")
self.assertEqual("====\nmsg\n====\n", h1)
def test_make_table_header(self):
actual = cliutils.make_table_header("Response Times (sec)", 40)
@ -253,7 +253,7 @@ class CliUtilsTestCase(test.TestCase):
pass
mock_obj = fake_class()
result = cliutils._methods_of(mock_obj)
self.assertEqual(result, [])
self.assertEqual([], result)
def _unregister_opts(self):
CONF.reset()
@ -267,19 +267,19 @@ class CliUtilsTestCase(test.TestCase):
side_effect=exceptions.RallyException("config_file"))
def test_run_fails(self, mock_rally_api_api):
ret = cliutils.run(["rally", "version"], self.categories)
self.assertEqual(ret, 2)
self.assertEqual(2, ret)
mock_rally_api_api.assert_called_once_with(
config_args=["version"], skip_db_check=True)
@mock.patch("rally.api.API.check_db_revision")
def test_run_version(self, mock_api_check_db_revision):
ret = cliutils.run(["rally", "version"], self.categories)
self.assertEqual(ret, 0)
self.assertEqual(0, ret)
@mock.patch("rally.api.API.check_db_revision")
def test_run_bash_completion(self, mock_api_check_db_revision):
ret = cliutils.run(["rally", "bash-completion"], self.categories)
self.assertEqual(ret, 0)
self.assertEqual(0, ret)
@mock.patch("rally.api.API.check_db_revision")
@mock.patch("rally.common.db.api.task_get",
@ -289,7 +289,7 @@ class CliUtilsTestCase(test.TestCase):
ret = cliutils.run(["rally", "task", "status", "%s" % FAKE_TASK_UUID],
self.categories)
self.assertTrue(mock_task_get.called)
self.assertEqual(ret, 1)
self.assertEqual(1, ret)
@mock.patch("rally.api.API.check_db_revision")
@mock.patch("rally.cli.cliutils.validate_args",
@ -299,7 +299,7 @@ class CliUtilsTestCase(test.TestCase):
ret = cliutils.run(["rally", "task", "status", "%s" % FAKE_TASK_UUID],
self.categories)
self.assertTrue(mock_validate_args.called)
self.assertEqual(ret, 1)
self.assertEqual(1, ret)
@mock.patch("rally.api.API.check_db_revision")
def test_run_failed_to_open_file(self, mock_api_check_db_revision):
@ -940,7 +940,7 @@ class ValidateArgsTest(test.TestCase):
alias_fn = mock.Mock(name="alias_fn")
cmd_name = "test-command"
wrapped = cliutils.alias(cmd_name)
self.assertEqual(wrapped(alias_fn).alias, cmd_name)
self.assertEqual(cmd_name, wrapped(alias_fn).alias)
class CategoryParserTestCase(test.TestCase):

@ -36,8 +36,8 @@ class EnvUtilsTestCase(test.TestCase):
with mock.patch("sys.stdout",
new_callable=moves.StringIO) as mock_stdout:
test_function()
self.assertEqual(mock_stdout.getvalue(),
"Missing argument: --test_missing_arg\n")
self.assertEqual("Missing argument: --test_missing_arg\n",
mock_stdout.getvalue())
@mock.patch.dict(os.environ,
values={envutils.ENV_DEPLOYMENT: "my_deployment_id"},
@ -91,7 +91,7 @@ class EnvUtilsTestCase(test.TestCase):
envutils.clear_global(envutils.ENV_DEPLOYMENT)
mock_update_env_file.assert_called_once_with(os.path.expanduser(
"~/.rally/globals"), envutils.ENV_DEPLOYMENT, "\n")
self.assertEqual(os.environ, {})
self.assertEqual({}, os.environ)
@mock.patch.dict(os.environ,
values={envutils.ENV_DEPLOYMENT: "test_deployment_id",
@ -102,7 +102,7 @@ class EnvUtilsTestCase(test.TestCase):
return_value=True)
def test_clear_env(self, mock_update_env_file, mock_path_exists):
envutils.clear_env()
self.assertEqual(os.environ, {})
self.assertEqual({}, os.environ)
@mock.patch.dict(os.environ, {"OS_AUTH_URL": "fake_auth_url",
"OS_USERNAME": "fake_username",

@ -68,27 +68,27 @@ class TasksTestCase(test.DBTestCase):
db_task = self._get_task(task["uuid"])
self.assertIsNotNone(db_task["uuid"])
self.assertIsNotNone(db_task["id"])
self.assertEqual(db_task["status"], consts.TaskStatus.INIT)
self.assertEqual(consts.TaskStatus.INIT, db_task["status"])
def test_task_create_with_tag(self):
task = self._create_task(values={"tags": ["test_tag"]})
db_task = self._get_task(task["uuid"])
self.assertIsNotNone(db_task["uuid"])
self.assertIsNotNone(db_task["id"])
self.assertEqual(db_task["status"], consts.TaskStatus.INIT)
self.assertEqual(db_task["tags"], ["test_tag"])
self.assertEqual(consts.TaskStatus.INIT, db_task["status"])
self.assertEqual(["test_tag"], db_task["tags"])
def test_task_create_without_uuid(self):
_uuid = "19be8589-48b0-4af1-a369-9bebaaa563ab"
task = self._create_task({"uuid": _uuid})
db_task = self._get_task(task["uuid"])
self.assertEqual(db_task["uuid"], _uuid)
self.assertEqual(_uuid, db_task["uuid"])
def test_task_update(self):
task = self._create_task({})
db.task_update(task["uuid"], {"status": consts.TaskStatus.CRASHED})
db_task = self._get_task(task["uuid"])
self.assertEqual(db_task["status"], consts.TaskStatus.CRASHED)
self.assertEqual(consts.TaskStatus.CRASHED, db_task["status"])
def test_task_update_with_tag(self):
task = self._create_task({})
@ -97,8 +97,8 @@ class TasksTestCase(test.DBTestCase):
"tags": ["test_tag"]
})
db_task = self._get_task(task["uuid"])
self.assertEqual(db_task["status"], consts.TaskStatus.CRASHED)
self.assertEqual(db_task["tags"], ["test_tag"])
self.assertEqual(consts.TaskStatus.CRASHED, db_task["status"])
self.assertEqual(["test_tag"], db_task["tags"])
def test_task_update_not_found(self):
self.assertRaises(exceptions.TaskNotFound,
@ -116,7 +116,7 @@ class TasksTestCase(test.DBTestCase):
for status in consts.TaskStatus:
db.task_update(_uuid, {"status": status})
db_task = self._get_task(_uuid)
self.assertEqual(db_task["status"], status)
self.assertEqual(status, db_task["status"])
def test_task_list_empty(self):
self.assertEqual([], db.task_list())
@ -308,8 +308,8 @@ class TasksTestCase(test.DBTestCase):
sla_results=sla_results)
detailed_task = db.task_get(task_id, detailed=True)
self.assertEqual(len(detailed_task["subtasks"]), 1)
self.assertEqual(len(detailed_task["subtasks"][0]["workloads"]), 1)
self.assertEqual(1, len(detailed_task["subtasks"]))
self.assertEqual(1, len(detailed_task["subtasks"][0]["workloads"]))
workload = detailed_task["subtasks"][0]["workloads"][0]
self.assertEqual([
{"error": "anError", "timestamp": 10, "duration": 1,
@ -550,71 +550,71 @@ class DeploymentTestCase(test.DBTestCase):
def test_deployment_create(self):
deploy = db.deployment_create({"config": {"opt": "val"}})
deploys = db.deployment_list()
self.assertEqual(len(deploys), 1)
self.assertEqual(deploy["uuid"], deploys[0]["uuid"])
self.assertEqual(deploy["status"], consts.DeployStatus.DEPLOY_INIT)
self.assertEqual(deploy["config"], {"opt": "val"})
self.assertEqual(deploy["credentials"], {})
self.assertEqual(1, len(deploys))
self.assertEqual(deploys[0]["uuid"], deploy["uuid"])
self.assertEqual(consts.DeployStatus.DEPLOY_INIT, deploy["status"])
self.assertEqual({"opt": "val"}, deploy["config"])
self.assertEqual({}, deploy["credentials"])
def test_deployment_create_several(self):
# Create a deployment
deploys = db.deployment_list()
self.assertEqual(len(deploys), 0)
self.assertEqual(0, len(deploys))
deploy_one = db.deployment_create({"config": {"opt1": "val1"}})
deploys = db.deployment_list()
self.assertEqual(len(deploys), 1)
self.assertEqual(deploy_one["uuid"], deploys[0]["uuid"])
self.assertEqual(deploy_one["status"], consts.DeployStatus.DEPLOY_INIT)
self.assertEqual(deploy_one["config"], {"opt1": "val1"})
self.assertEqual(1, len(deploys))
self.assertEqual(deploys[0]["uuid"], deploy_one["uuid"])
self.assertEqual(consts.DeployStatus.DEPLOY_INIT, deploy_one["status"])
self.assertEqual({"opt1": "val1"}, deploy_one["config"])
# Create another deployment and sure that they are different
deploy_two = db.deployment_create({"config": {"opt2": "val2"}})
deploys = db.deployment_list()
self.assertEqual(len(deploys), 2)
self.assertEqual(2, len(deploys))
self.assertEqual(set([deploy_one["uuid"], deploy_two["uuid"]]),
set([deploy["uuid"] for deploy in deploys]))
self.assertNotEqual(deploy_one["uuid"], deploy_two["uuid"])
self.assertEqual(deploy_two["status"], consts.DeployStatus.DEPLOY_INIT)
self.assertEqual(deploy_two["config"], {"opt2": "val2"})
self.assertEqual(consts.DeployStatus.DEPLOY_INIT, deploy_two["status"])
self.assertEqual({"opt2": "val2"}, deploy_two["config"])
def test_deployment_update(self):
credentials = {
"openstack": [{"admin": {"foo": "bar"}, "users": ["foo_user"]}]}
deploy = db.deployment_create({})
self.assertEqual(deploy["config"], {})
self.assertEqual(deploy["credentials"], {})
self.assertEqual({}, deploy["config"])
self.assertEqual({}, deploy["credentials"])
update_deploy = db.deployment_update(
deploy["uuid"], {"config": {"opt": "val"},
"credentials": copy.deepcopy(credentials)})
self.assertEqual(update_deploy["uuid"], deploy["uuid"])
self.assertEqual(update_deploy["config"], {"opt": "val"})
self.assertEqual(update_deploy["credentials"], credentials)
self.assertEqual(deploy["uuid"], update_deploy["uuid"])
self.assertEqual({"opt": "val"}, update_deploy["config"])
self.assertEqual(credentials, update_deploy["credentials"])
get_deploy = db.deployment_get(deploy["uuid"])
self.assertEqual(get_deploy["uuid"], deploy["uuid"])
self.assertEqual(get_deploy["config"], {"opt": "val"})
self.assertEqual(update_deploy["credentials"], credentials)
self.assertEqual(deploy["uuid"], get_deploy["uuid"])
self.assertEqual({"opt": "val"}, get_deploy["config"])
self.assertEqual(credentials, update_deploy["credentials"])
def test_deployment_update_several(self):
# Create a deployment and update it
deploy_one = db.deployment_create({})
self.assertEqual(deploy_one["config"], {})
self.assertEqual({}, deploy_one["config"])
update_deploy_one = db.deployment_update(
deploy_one["uuid"], {"config": {"opt1": "val1"}})
self.assertEqual(update_deploy_one["uuid"], deploy_one["uuid"])
self.assertEqual(update_deploy_one["config"], {"opt1": "val1"})
self.assertEqual(deploy_one["uuid"], update_deploy_one["uuid"])
self.assertEqual({"opt1": "val1"}, update_deploy_one["config"])
get_deploy_one = db.deployment_get(deploy_one["uuid"])
self.assertEqual(get_deploy_one["uuid"], deploy_one["uuid"])
self.assertEqual(get_deploy_one["config"], {"opt1": "val1"})
self.assertEqual(deploy_one["uuid"], get_deploy_one["uuid"])
self.assertEqual({"opt1": "val1"}, get_deploy_one["config"])
# Create another deployment
deploy_two = db.deployment_create({})
update_deploy_two = db.deployment_update(
deploy_two["uuid"], {"config": {"opt2": "val2"}})
self.assertEqual(update_deploy_two["uuid"], deploy_two["uuid"])
self.assertEqual(update_deploy_two["config"], {"opt2": "val2"})
self.assertEqual(deploy_two["uuid"], update_deploy_two["uuid"])
self.assertEqual({"opt2": "val2"}, update_deploy_two["config"])
get_deploy_one_again = db.deployment_get(deploy_one["uuid"])
self.assertEqual(get_deploy_one_again["uuid"], deploy_one["uuid"])
self.assertEqual(get_deploy_one_again["config"], {"opt1": "val1"})
self.assertEqual(deploy_one["uuid"], get_deploy_one_again["uuid"])
self.assertEqual({"opt1": "val1"}, get_deploy_one_again["config"])
def test_deployment_get(self):
deploy_one = db.deployment_create({"config": {"opt1": "val1"}})
@ -622,8 +622,8 @@ class DeploymentTestCase(test.DBTestCase):
get_deploy_one = db.deployment_get(deploy_one["uuid"])
get_deploy_two = db.deployment_get(deploy_two["uuid"])
self.assertNotEqual(get_deploy_one["uuid"], get_deploy_two["uuid"])
self.assertEqual(get_deploy_one["config"], {"opt1": "val1"})
self.assertEqual(get_deploy_two["config"], {"opt2": "val2"})
self.assertEqual({"opt1": "val1"}, get_deploy_one["config"])
self.assertEqual({"opt2": "val2"}, get_deploy_two["config"])
def test_deployment_get_not_found(self):
self.assertRaises(exceptions.DeploymentNotFound,
@ -646,17 +646,17 @@ class DeploymentTestCase(test.DBTestCase):
deploy_three = db.deployment_create({"name": "deployment_name"})
deploys = db.deployment_list(status=consts.DeployStatus.DEPLOY_INIT)
deploys.sort(key=lambda x: x["id"])
self.assertEqual(len(deploys), 2)
self.assertEqual(deploys[0]["uuid"], deploy_one["uuid"])
self.assertEqual(2, len(deploys))
self.assertEqual(deploy_one["uuid"], deploys[0]["uuid"])
deploys = db.deployment_list(status=consts.DeployStatus.DEPLOY_FAILED)
self.assertEqual(len(deploys), 1)
self.assertEqual(deploys[0]["uuid"], deploy_two["uuid"])
self.assertEqual(1, len(deploys))
self.assertEqual(deploy_two["uuid"], deploys[0]["uuid"])
deploys = db.deployment_list(
status=consts.DeployStatus.DEPLOY_FINISHED)
self.assertEqual(len(deploys), 0)
self.assertEqual(0, len(deploys))
deploys = db.deployment_list(name="deployment_name")
self.assertEqual(deploys[0]["uuid"], deploy_three["uuid"])
self.assertEqual(len(deploys), 1)
self.assertEqual(deploy_three["uuid"], deploys[0]["uuid"])
self.assertEqual(1, len(deploys))
def test_deployment_list_parent(self):
deploy = db.deployment_create({})
@ -673,8 +673,8 @@ class DeploymentTestCase(test.DBTestCase):
deploy_two = db.deployment_create({})
db.deployment_delete(deploy_two["uuid"])
deploys = db.deployment_list()
self.assertEqual(len(deploys), 1)
self.assertEqual(deploys[0]["uuid"], deploy_one["uuid"])
self.assertEqual(1, len(deploys))
self.assertEqual(deploy_one["uuid"], deploys[0]["uuid"])
def test_deployment_delete_not_found(self):
self.assertRaises(exceptions.DeploymentNotFound,
@ -699,18 +699,18 @@ class ResourceTestCase(test.DBTestCase):
})
resources = db.resource_get_all(deployment["uuid"])
self.assertTrue(resource["id"])
self.assertEqual(len(resources), 1)
self.assertTrue(resource["id"], resources[0]["id"])
self.assertEqual(resource["deployment_uuid"], deployment["uuid"])
self.assertEqual(resource["provider_name"], "fakeprovider")
self.assertEqual(resource["type"], "faketype")
self.assertEqual(1, len(resources))
self.assertTrue(resources[0]["id"], resource["id"])
self.assertEqual(deployment["uuid"], resource["deployment_uuid"])
self.assertEqual("fakeprovider", resource["provider_name"])
self.assertEqual("faketype", resource["type"])
def test_delete(self):
deployment = db.deployment_create({})
res = db.resource_create({"deployment_uuid": deployment["uuid"]})
db.resource_delete(res["id"])
resources = db.resource_get_all(deployment["uuid"])
self.assertEqual(len(resources), 0)
self.assertEqual(0, len(resources))
def test_delete_not_found(self):
self.assertRaises(exceptions.ResourceNotFound,
@ -726,7 +726,7 @@ class ResourceTestCase(test.DBTestCase):
self.assertEqual(sorted([res1["id"], res2["id"]]),
sorted([r["id"] for r in resources]))
resources = db.resource_get_all(deployment0["uuid"])
self.assertEqual(len(resources), 1)
self.assertEqual(1, len(resources))
self.assertEqual(res0["id"], resources[0]["id"])
def test_get_all_by_provider_name(self):
@ -741,11 +741,11 @@ class ResourceTestCase(test.DBTestCase):
})
resources = db.resource_get_all(deployment["uuid"],
provider_name="one")
self.assertEqual(len(resources), 1)
self.assertEqual(1, len(resources))
self.assertEqual(res_one["id"], resources[0]["id"])
resources = db.resource_get_all(deployment["uuid"],
provider_name="two")
self.assertEqual(len(resources), 1)
self.assertEqual(1, len(resources))
self.assertEqual(res_two["id"], resources[0]["id"])
def test_get_all_by_provider_type(self):
@ -759,10 +759,10 @@ class ResourceTestCase(test.DBTestCase):
"type": "two",
})
resources = db.resource_get_all(deployment["uuid"], type="one")
self.assertEqual(len(resources), 1)
self.assertEqual(1, len(resources))
self.assertEqual(res_one["id"], resources[0]["id"])
resources = db.resource_get_all(deployment["uuid"], type="two")
self.assertEqual(len(resources), 1)
self.assertEqual(1, len(resources))
self.assertEqual(res_two["id"], resources[0]["id"])
@ -787,7 +787,7 @@ class VerifierTestCase(test.DBTestCase):
v1 = db.verifier_update(v1["uuid"], status="foo")
vs = db.verifier_list(status="foo")
self.assertEqual(len(vs), 1)
self.assertEqual(1, len(vs))
self.assertEqual(v1["uuid"], vs[0]["uuid"])
def test_verifier_delete(self):
@ -840,16 +840,16 @@ class VerificationTestCase(test.DBTestCase):
sorted([v["uuid"] for v in vs]))
vs = db.verification_list(self.verifier["uuid"], deploy["uuid"])
self.assertEqual(len(vs), 1)
self.assertEqual(1, len(vs))
self.assertEqual(v1["uuid"], vs[0]["uuid"])
vs = db.verification_list(tags=["bar"])
self.assertEqual(len(vs), 1)
self.assertEqual(1, len(vs))
self.assertEqual(v1["uuid"], vs[0]["uuid"])
v2 = db.verification_update(v2["uuid"], status="foo")
vs = db.verification_list(status="foo")
self.assertEqual(len(vs), 1)
self.assertEqual(1, len(vs))
self.assertEqual(v2["uuid"], vs[0]["uuid"])
def test_verification_delete(self):

@ -230,7 +230,7 @@ class MigrationWalkTestCase(rtest.DBTestCase,
def assertColumnCount(self, engine, table, columns):
t = db_utils.get_table(engine, table)
self.assertEqual(len(t.columns), len(columns))
self.assertEqual(len(columns), len(t.columns))
def assertColumnNotExists(self, engine, table, column):
t = db_utils.get_table(engine, table)
@ -419,7 +419,7 @@ class MigrationWalkTestCase(rtest.DBTestCase,
"name": self._08e1515a576c_deployment_uuid,
"config": six.b("{}"),
"enum_deployments_status":
consts.DeployStatus.DEPLOY_FINISHED,
consts.DeployStatus.DEPLOY_FINISHED,
"credentials": six.b(json.dumps([])),
"users": six.b(json.dumps([]))
}])
@ -544,21 +544,21 @@ class MigrationWalkTestCase(rtest.DBTestCase,
where(task_table.c.uuid == self._e654a0648db0_task_uuid)
).fetchall()
self.assertEqual(len(tasks_found), 1)
self.assertEqual(1, len(tasks_found))
task_found = tasks_found[0]
self.assertEqual(task_found.uuid, self._e654a0648db0_task_uuid)
self.assertEqual(task_found.deployment_uuid,
self._e654a0648db0_deployment_uuid)
self.assertEqual(task_found.status, consts.TaskStatus.FINISHED)
self.assertEqual(self._e654a0648db0_task_uuid, task_found.uuid)
self.assertEqual(self._e654a0648db0_deployment_uuid,
task_found.deployment_uuid)
self.assertEqual(consts.TaskStatus.FINISHED, task_found.status)
# NOTE(ikhudoshyn): if for all workloads success == True
self.assertEqual(task_found.pass_sla, False)
self.assertFalse(task_found.pass_sla)
# NOTE(ikhudoshyn): sum of all full_durations of all workloads
self.assertEqual(task_found.task_duration, 142)
self.assertEqual(142, task_found.task_duration)
# NOTE(ikhudoshyn): we have no info on validation duration in old
# schema
self.assertEqual(task_found.validation_duration, 0)
self.assertEqual(json.loads(task_found.validation_result), {})
self.assertEqual(0, task_found.validation_duration)
self.assertEqual({}, json.loads(task_found.validation_result))
# Check subtask
@ -568,16 +568,16 @@ class MigrationWalkTestCase(rtest.DBTestCase,
self._e654a0648db0_task_uuid)
).fetchall()
self.assertEqual(len(subtasks_found), 1)
self.assertEqual(1, len(subtasks_found))
subtask_found = subtasks_found[0]
self.assertEqual(subtask_found.task_uuid,
self._e654a0648db0_task_uuid)
self.assertEqual(self._e654a0648db0_task_uuid,
subtask_found.task_uuid)
# NOTE(ikhudoshyn): if for all workloads success == True
self.assertEqual(subtask_found.pass_sla, False)
self.assertFalse(subtask_found.pass_sla)
# NOTE(ikhudoshyn): sum of all full_durations of all workloads
self.assertEqual(subtask_found.duration, 142)
self.assertEqual(142, subtask_found.duration)
self._e654a0648db0_subtask_uuid = subtask_found.uuid
@ -588,9 +588,9 @@ class MigrationWalkTestCase(rtest.DBTestCase,
where(tag_table.c.uuid == self._e654a0648db0_task_uuid)
).fetchall()
self.assertEqual(len(tags_found), 1)
self.assertEqual(tags_found[0].tag, "test_tag")
self.assertEqual(tags_found[0].type, consts.TagType.TASK)
self.assertEqual(1, len(tags_found))
self.assertEqual("test_tag", tags_found[0].tag)
self.assertEqual(consts.TagType.TASK, tags_found[0].type)
# Check workload
@ -600,43 +600,36 @@ class MigrationWalkTestCase(rtest.DBTestCase,
self._e654a0648db0_task_uuid)
).fetchall()
self.assertEqual(len(workloads_found), 1)
self.assertEqual(1, len(workloads_found))
workload_found = workloads_found[0]
self.assertEqual(workload_found.task_uuid,
self._e654a0648db0_task_uuid)
self.assertEqual(workload_found.subtask_uuid,
self._e654a0648db0_subtask_uuid)
self.assertEqual(workload_found.name, "test_scenario")
self.assertEqual(workload_found.position, 0)
self.assertEqual(workload_found.runner_type, "theRunner")
self.assertEqual(workload_found.runner,
json.dumps({"type": "theRunner"}))
self.assertEqual(workload_found.sla,
json.dumps({"s": "S"}))
self.assertEqual(workload_found.args,
json.dumps({"a": "A"}))
self.assertEqual(workload_found.context,
json.dumps({"c": "C"}))
self.assertEqual(workload_found.sla_results,
json.dumps({
"sla": [
{"success": True},
{"success": False}
]
}))
self.assertEqual(workload_found.context_execution,
json.dumps({}))
self.assertEqual(workload_found.load_duration, 42)
self.assertEqual(workload_found.full_duration, 142)
self.assertEqual(workload_found.min_duration, 1)
self.assertEqual(workload_found.max_duration, 8)
self.assertEqual(workload_found.total_iteration_count, 3)
self.assertEqual(workload_found.failed_iteration_count, 1)
self.assertEqual(workload_found.pass_sla, False)
self.assertEqual(self._e654a0648db0_task_uuid,
workload_found.task_uuid)
self.assertEqual(self._e654a0648db0_subtask_uuid,
workload_found.subtask_uuid)
self.assertEqual("test_scenario", workload_found.name)
self.assertEqual(0, workload_found.position)
self.assertEqual("theRunner", workload_found.runner_type)
self.assertEqual(json.dumps({"type": "theRunner"}),
workload_found.runner)
self.assertEqual(json.dumps({"s": "S"}), workload_found.sla)
self.assertEqual(json.dumps({"a": "A"}), workload_found.args)
self.assertEqual(json.dumps({"c": "C"}), workload_found.context)
self.assertEqual(json.dumps({
"sla": [{"success": True},
{"success": False}]
}), workload_found.sla_results)
self.assertEqual(json.dumps({}), workload_found.context_execution)
self.assertEqual(42, workload_found.load_duration)
self.assertEqual(142, workload_found.full_duration)
self.assertEqual(1, workload_found.min_duration)
self.assertEqual(8, workload_found.max_duration)
self.assertEqual(3, workload_found.total_iteration_count)
self.assertEqual(1, workload_found.failed_iteration_count)
self.assertFalse(workload_found.pass_sla)
self._e654a0648db0_workload_uuid = workload_found.uuid
@ -648,23 +641,22 @@ class MigrationWalkTestCase(rtest.DBTestCase,
self._e654a0648db0_task_uuid)
).fetchall()
self.assertEqual(len(workloaddata_found), 1)
self.assertEqual(1, len(workloaddata_found))
wloaddata_found = workloaddata_found[0]
self.assertEqual(wloaddata_found.task_uuid,
self._e654a0648db0_task_uuid)
self.assertEqual(self._e654a0648db0_task_uuid,
wloaddata_found.task_uuid)
self.assertEqual(wloaddata_found.workload_uuid,
self._e654a0648db0_workload_uuid)
self.assertEqual(self._e654a0648db0_workload_uuid,
wloaddata_found.workload_uuid)
self.assertEqual(wloaddata_found.chunk_order, 0)
self.assertEqual(wloaddata_found.chunk_size, 0)
self.assertEqual(wloaddata_found.compressed_chunk_size, 0)
self.assertEqual(wloaddata_found.iteration_count, 3)
self.assertEqual(wloaddata_found.failed_iteration_count, 1)
self.assertEqual(0, wloaddata_found.chunk_order)
self.assertEqual(0, wloaddata_found.chunk_size)
self.assertEqual(0, wloaddata_found.compressed_chunk_size)
self.assertEqual(3, wloaddata_found.iteration_count)
self.assertEqual(1, wloaddata_found.failed_iteration_count)
self.assertEqual(
wloaddata_found.chunk_data,
json.dumps(
{
"raw": [
@ -673,7 +665,7 @@ class MigrationWalkTestCase(rtest.DBTestCase,
{"duration": 8},
]
}
)
), wloaddata_found.chunk_data
)
# Delete all stuff created at _pre_upgrade step
@ -939,7 +931,7 @@ class MigrationWalkTestCase(rtest.DBTestCase,
verifications_table.insert(),
[{"uuid": vuuid,
"deployment_uuid":
self._484cd9413e66_deployment_uuid,
self._484cd9413e66_deployment_uuid,
"status": vstatus,
"set_name": verification["set_name"],
"tests": verification["total"]["tests"],
@ -1286,7 +1278,7 @@ class MigrationWalkTestCase(rtest.DBTestCase,
"name": self._4ef544102ba7_deployment_uuid,
"config": six.b(json.dumps([])),
"enum_deployments_status":
consts.DeployStatus.DEPLOY_FINISHED,
consts.DeployStatus.DEPLOY_FINISHED,
"credentials": six.b(json.dumps([])),
"users": six.b(json.dumps([]))
}])

@ -50,20 +50,20 @@ class DeploymentTestCase(test.TestCase):
mock_deployment_create.return_value = self.deployment
deploy = objects.Deployment()
mock_deployment_create.assert_called_once_with({})
self.assertEqual(deploy["uuid"], self.deployment["uuid"])
self.assertEqual(self.deployment["uuid"], deploy["uuid"])
@mock.patch("rally.common.objects.deploy.db.deployment_create")
def test_init_without_create(self, mock_deployment_create):
deploy = objects.Deployment(deployment=self.deployment)
self.assertFalse(mock_deployment_create.called)
self.assertEqual(deploy["uuid"], self.deployment["uuid"])
self.assertEqual(self.deployment["uuid"], deploy["uuid"])
@mock.patch("rally.common.objects.deploy.db.deployment_get")
def test_get(self, mock_deployment_get):
mock_deployment_get.return_value = self.deployment
deploy = objects.Deployment.get(self.deployment["uuid"])
mock_deployment_get.assert_called_once_with(self.deployment["uuid"])
self.assertEqual(deploy["uuid"], self.deployment["uuid"])
self.assertEqual(self.deployment["uuid"], deploy["uuid"])
@mock.patch("rally.common.objects.deploy.db.deployment_delete")
@mock.patch("rally.common.objects.deploy.db.deployment_create")
@ -88,7 +88,7 @@ class DeploymentTestCase(test.TestCase):
deploy._update({"opt": "val2"})
mock_deployment_update.assert_called_once_with(
self.deployment["uuid"], {"opt": "val2"})
self.assertEqual(deploy["opt"], "val2")
self.assertEqual("val2", deploy["opt"])
@mock.patch("rally.common.objects.deploy.db.deployment_update")
def test_update_status(self, mock_deployment_update):
@ -250,7 +250,7 @@ class DeploymentTestCase(test.TestCase):
deploy = objects.Deployment(deployment=self.deployment)
resource = deploy.add_resource("provider", type="some",
info={"key": "value"})
self.assertEqual(resource["id"], self.resource["id"])
self.assertEqual(self.resource["id"], resource["id"])
mock_resource_create.assert_called_once_with({
"deployment_uuid": self.deployment["uuid"],
"provider_name": "provider",
@ -268,8 +268,8 @@ class DeploymentTestCase(test.TestCase):
mock_resource_get_all.return_value = [self.resource]
deploy = objects.Deployment(deployment=self.deployment)
resources = deploy.get_resources(provider_name="provider", type="some")
self.assertEqual(len(resources), 1)
self.assertEqual(resources[0]["id"], self.resource["id"])
self.assertEqual(1, len(resources))
self.assertEqual(self.resource["id"], resources[0]["id"])
@mock.patch("rally.common.objects.deploy.dt.datetime")
@mock.patch("rally.common.objects.deploy.db.deployment_update")

@ -66,7 +66,7 @@ class TestMetaMixinTestCase(test.TestCase):
Meta._meta_init()
Meta._meta_set("aaa", 42)
self.assertEqual(Meta._meta_get("aaa"), 42)
self.assertEqual(42, Meta._meta_get("aaa"))
def test_meta_get_default(self):
@ -74,7 +74,7 @@ class TestMetaMixinTestCase(test.TestCase):
pass
Meta._meta_init()
self.assertEqual(Meta._meta_get("b", 42), 42)
self.assertEqual(42, Meta._meta_get("b", 42))
def test_meta_get_if_is_not_inited(self):

@ -79,8 +79,8 @@ class PluginModuleTestCase(test.TestCase):
class B(SecondBase):
pass
self.assertEqual(A, OneBase.get(name))
self.assertEqual(B, SecondBase.get(name))
self.assertEqual(OneBase.get(name), A)
self.assertEqual(SecondBase.get(name), B)
def test_get_multiple_chooses(self):
name = "test_get_multiple_chooses"
@ -221,5 +221,5 @@ class PluginTestCase(test.TestCase):
def test_is_deprecated(self):
self.assertFalse(SomePlugin.is_deprecated())
self.assertEqual(DeprecatedPlugin.is_deprecated(),
{"reason": "some_reason", "rally_version": "0.1.1"})
self.assertEqual({"reason": "some_reason", "rally_version": "0.1.1"},
DeprecatedPlugin.is_deprecated())

@ -224,14 +224,14 @@ class LogTestCase(test.TestCase):
return x + y
t = TaskLog()
self.assertEqual(t.some_method.__name__, "some_method")
self.assertEqual(t.some_method(2, 2), 4)
self.assertEqual("some_method", t.some_method.__name__)
self.assertEqual(4, t.some_method(2, 2))
params = {"msg": msg % {"a": 10, "b": 20}, "uuid": t.task["uuid"]}
expected = [
mock.call(_("Task %(uuid)s | Starting: %(msg)s") % params),
mock.call(_("Task %(uuid)s | Completed: %(msg)s") % params)
]
self.assertEqual(mock_log.mock_calls, expected)
self.assertEqual(expected, mock_log.mock_calls)
def test_log_deprecated(self):
mock_log = mock.MagicMock()
@ -240,7 +240,7 @@ class LogTestCase(test.TestCase):
def some_method(x, y):
return x + y
self.assertEqual(some_method(2, 2), 4)
self.assertEqual(4, some_method(2, 2))
self.assertIn("some_method()", mock_log.call_args[0][0])
self.assertIn("depr42", mock_log.call_args[0][0])
self.assertIn("1.1.1", mock_log.call_args[0][0])
@ -253,13 +253,13 @@ class LogTestCase(test.TestCase):
def some_method(x, y, z):
return x + y + z
self.assertEqual(some_method(2, 2, z=3), 7)
self.assertEqual(7, some_method(2, 2, z=3))
self.assertIn("ABC42", mock_log.call_args[0][0])
self.assertIn("`z' of `some_method()'", mock_log.call_args[0][0])
self.assertIn("0.0.1", mock_log.call_args[0][0])
mock_log.reset_mock()
self.assertEqual(some_method(2, 2, z=3), 7)
self.assertEqual(7, some_method(2, 2, z=3))
self.assertFalse(mock_log.called)
@rally_logging.log_deprecated_args("CBA42", "0.0.1", ("z",),
@ -267,9 +267,9 @@ class LogTestCase(test.TestCase):
def some_method(x, y, z):
return x + y + z
self.assertEqual(some_method(2, 2, z=3), 7)
self.assertEqual(7, some_method(2, 2, z=3))
self.assertIn("CBA42", mock_log.call_args[0][0])
mock_log.reset_mock()
self.assertEqual(some_method(2, 2, z=3), 7)
self.assertEqual(7, some_method(2, 2, z=3))
self.assertIn("CBA42", mock_log.call_args[0][0])

@ -76,7 +76,7 @@ class SSHTestCase(test.TestCase):
key = self.ssh._get_pkey("key")
dss_calls = mock_paramiko.dsskey.DSSKey.from_private_key.mock_calls
self.assertEqual([mock.call("string_key")], dss_calls)
self.assertEqual(key, "dss_key")
self.assertEqual("dss_key", key)
mock_string_io.assert_called_once_with("key")
@mock.patch("rally.common.sshutils.six.moves.StringIO")
@ -90,7 +90,7 @@ class SSHTestCase(test.TestCase):
key = self.ssh._get_pkey("key")
rsa_calls = mock_paramiko.rsakey.RSAKey.from_private_key.mock_calls
self.assertEqual([mock.call("string_key")], rsa_calls)
self.assertEqual(key, "rsa_key")
self.assertEqual("rsa_key", key)
mock_string_io.assert_called_once_with("key")
@mock.patch("rally.common.sshutils.SSH._get_pkey")

@ -46,7 +46,7 @@ class ImmutableMixinTestCase(test.TestCase):
a = A("test")
self.assertRaises(AttributeError,
a.__setattr__, "abc", "test")
self.assertEqual(a.test, "test")
self.assertEqual("test", a.test)
class EnumMixinTestCase(test.TestCase):
@ -58,7 +58,7 @@ class EnumMixinTestCase(test.TestCase):
b = 20
CC = "2000"
self.assertEqual(set(list(Foo())), set([10, 20, "2000"]))
self.assertEqual(set([10, 20, "2000"]), set(list(Foo())))
def test_with_underscore(self):
@ -67,7 +67,7 @@ class EnumMixinTestCase(test.TestCase):
b = 20
_CC = "2000"
self.assertEqual(set(list(Foo())), set([10, 20]))
self.assertEqual(set([10, 20]), set(list(Foo())))
class StdIOCaptureTestCase(test.TestCase):
@ -79,8 +79,8 @@ class StdIOCaptureTestCase(test.TestCase):
for msg in messages:
print(msg)
self.assertEqual(out.getvalue().rstrip("\n").split("\n"), messages)
self.assertEqual(stdout, sys.stdout)
self.assertEqual(messages, out.getvalue().rstrip("\n").split("\n"))
self.assertEqual(sys.stdout, stdout)
def test_stderr_capture(self):
stderr = sys.stderr
@ -89,8 +89,8 @@ class StdIOCaptureTestCase(test.TestCase):
for msg in messages:
print(msg, file=sys.stderr)
self.assertEqual(err.getvalue().rstrip("\n").split("\n"), messages)
self.assertEqual(stderr, sys.stderr)
self.assertEqual(messages, err.getvalue().rstrip("\n").split("\n"))
self.assertEqual(sys.stderr, stderr)
class TimerTestCase(test.TestCase):
@ -141,9 +141,9 @@ class FirstIndexTestCase(test.TestCase):
def test_list_with_existing_matching_element(self):
lst = [1, 3, 5, 7]
self.assertEqual(utils.first_index(lst, lambda e: e == 1), 0)
self.assertEqual(utils.first_index(lst, lambda e: e == 5), 2)
self.assertEqual(utils.first_index(lst, lambda e: e == 7), 3)
self.assertEqual(0, utils.first_index(lst, lambda e: e == 1))
self.assertEqual(2, utils.first_index(lst, lambda e: e == 5))
self.assertEqual(3, utils.first_index(lst, lambda e: e == 7))
def test_list_with_non_existing_matching_element(self):
lst = [1, 3, 5, 7]
@ -242,7 +242,7 @@ class RandomNameTestCase(test.TestCase):
generator = FakeNameGenerator()
mock_choice.side_effect = iter("blarglesdweebled")
self.assertEqual(generator.generate_random_name(), expected)
self.assertEqual(expected, generator.generate_random_name())
class FakeNameGenerator(utils.RandomNameGeneratorMixin):
RESOURCE_NAME_FORMAT = fmt
@ -251,7 +251,7 @@ class RandomNameTestCase(test.TestCase):
generator = FakeNameGenerator()
mock_choice.side_effect = iter("blarglesdweebled")
self.assertEqual(generator.generate_random_name(), expected)
self.assertEqual(expected, generator.generate_random_name())
def test_generate_random_name_bogus_name_format(self):
class FakeNameGenerator(utils.RandomNameGeneratorMixin):
@ -393,13 +393,13 @@ class RandomNameTestCase(test.TestCase):
names = [generator.generate_random_name() for i in range(100)]
task_id_parts = set([n.split("_")[0] for n in names])
self.assertEqual(len(task_id_parts), 1)
self.assertEqual(1, len(task_id_parts))
generator.task = {"uuid": "bogus! task! id!"}
names = [generator.generate_random_name() for i in range(100)]
task_id_parts = set([n.split("_")[0] for n in names])
self.assertEqual(len(task_id_parts), 1)
self.assertEqual(1, len(task_id_parts))
def test_make_name_matcher(self):
matcher = utils.make_name_matcher("foo", "bar")
@ -457,7 +457,7 @@ class MergeTestCase(test.TestCase):
in_iters = [iter(src) for src in sources]
out = list(utils.merge(10, *in_iters))
self.assertEqual(out, expected_output)
self.assertEqual(expected_output, out)
class TimeoutThreadTestCase(test.TestCase):
@ -506,10 +506,10 @@ class LockedDictTestCase(test.TestCase):
d = utils.LockedDict()
self.assertIsInstance(d, dict)
self.assertEqual(d, {})
self.assertEqual({}, d)
d = utils.LockedDict(foo="bar", spam={"a": ["b", {"c": "d"}]})
self.assertEqual(d, {"foo": "bar", "spam": {"a": ("b", {"c": "d"})}})
self.assertEqual({"foo": "bar", "spam": {"a": ("b", {"c": "d"})}}, d)
self.assertIsInstance(d["spam"], utils.LockedDict)
self.assertIsInstance(d["spam"]["a"][1], utils.LockedDict)
self.assertRaises(RuntimeError, setitem, d, 123, 456)
@ -521,21 +521,21 @@ class LockedDictTestCase(test.TestCase):
self.assertRaises(RuntimeError, d.pop, "foo")
self.assertRaises(RuntimeError, d.popitem)
self.assertRaises(RuntimeError, d.clear)
self.assertEqual(d, {"foo": "bar", "spam": {"a": ("b", {"c": "d"})}})
self.assertEqual({"foo": "bar", "spam": {"a": ("b", {"c": "d"})}}, d)
with d.unlocked():
d["spam"] = 42
self.assertEqual(d, {"foo": "bar", "spam": 42})
self.assertEqual({"foo": "bar", "spam": 42}, d)
d.clear()
self.assertEqual(d, {})
self.assertEqual({}, d)
d.setdefault("foo", 42)
d.update({"bar": 24})
self.assertEqual(d, {"foo": 42, "bar": 24})
self.assertEqual({"foo": 42, "bar": 24}, d)
self.assertEqual(24, d.pop("bar"))
self.assertEqual(("foo", 42), d.popitem())
d[123] = 456
self.assertEqual(d, {123: 456})
self.assertEqual({123: 456}, d)
self.assertRaises(RuntimeError, setitem, d, 123, 456)
self.assertRaises(RuntimeError, delitem, d, "foo")
@ -798,7 +798,7 @@ class BackupTestCase(test.TestCas