Replace ' with " in tests/unit/verification
Partial bug: 1405884 Change-Id: I6f4e08a04ce1e67fa4bedf299b9c7f8def36902b
This commit is contained in:
parent
d347a9d9e5
commit
246975a5c9
@ -27,95 +27,95 @@ class DeploymentTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(DeploymentTestCase, self).setUp()
|
||||
self.deployment = {
|
||||
'uuid': 'baa1bfb6-0c38-4f6c-9bd0-45968890e4f4',
|
||||
'name': '',
|
||||
'config': {},
|
||||
'endpoint': {},
|
||||
'status': consts.DeployStatus.DEPLOY_INIT,
|
||||
"uuid": "baa1bfb6-0c38-4f6c-9bd0-45968890e4f4",
|
||||
"name": "",
|
||||
"config": {},
|
||||
"endpoint": {},
|
||||
"status": consts.DeployStatus.DEPLOY_INIT,
|
||||
}
|
||||
self.resource = {
|
||||
'id': 42,
|
||||
'deployment_uuid': self.deployment['uuid'],
|
||||
'provider_name': 'provider',
|
||||
'type': 'some',
|
||||
'info': {'key': 'value'},
|
||||
"id": 42,
|
||||
"deployment_uuid": self.deployment["uuid"],
|
||||
"provider_name": "provider",
|
||||
"type": "some",
|
||||
"info": {"key": "value"},
|
||||
}
|
||||
|
||||
@mock.patch('rally.objects.deploy.db.deployment_create')
|
||||
@mock.patch("rally.objects.deploy.db.deployment_create")
|
||||
def test_init_with_create(self, mock_create):
|
||||
mock_create.return_value = self.deployment
|
||||
deploy = objects.Deployment()
|
||||
mock_create.assert_called_once_with({})
|
||||
self.assertEqual(deploy['uuid'], self.deployment['uuid'])
|
||||
self.assertEqual(deploy["uuid"], self.deployment["uuid"])
|
||||
|
||||
@mock.patch('rally.objects.deploy.db.deployment_create')
|
||||
@mock.patch("rally.objects.deploy.db.deployment_create")
|
||||
def test_init_without_create(self, mock_create):
|
||||
deploy = objects.Deployment(deployment=self.deployment)
|
||||
self.assertFalse(mock_create.called)
|
||||
self.assertEqual(deploy['uuid'], self.deployment['uuid'])
|
||||
self.assertEqual(deploy["uuid"], self.deployment["uuid"])
|
||||
|
||||
@mock.patch('rally.objects.deploy.db.deployment_get')
|
||||
@mock.patch("rally.objects.deploy.db.deployment_get")
|
||||
def test_get(self, mock_get):
|
||||
mock_get.return_value = self.deployment
|
||||
deploy = objects.Deployment.get(self.deployment['uuid'])
|
||||
mock_get.assert_called_once_with(self.deployment['uuid'])
|
||||
self.assertEqual(deploy['uuid'], self.deployment['uuid'])
|
||||
deploy = objects.Deployment.get(self.deployment["uuid"])
|
||||
mock_get.assert_called_once_with(self.deployment["uuid"])
|
||||
self.assertEqual(deploy["uuid"], self.deployment["uuid"])
|
||||
|
||||
@mock.patch('rally.objects.deploy.db.deployment_delete')
|
||||
@mock.patch('rally.objects.deploy.db.deployment_create')
|
||||
@mock.patch("rally.objects.deploy.db.deployment_delete")
|
||||
@mock.patch("rally.objects.deploy.db.deployment_create")
|
||||
def test_create_and_delete(self, mock_create, mock_delete):
|
||||
mock_create.return_value = self.deployment
|
||||
deploy = objects.Deployment()
|
||||
deploy.delete()
|
||||
mock_delete.assert_called_once_with(self.deployment['uuid'])
|
||||
mock_delete.assert_called_once_with(self.deployment["uuid"])
|
||||
|
||||
@mock.patch('rally.objects.deploy.db.deployment_delete')
|
||||
@mock.patch("rally.objects.deploy.db.deployment_delete")
|
||||
def test_delete_by_uuid(self, mock_delete):
|
||||
objects.Deployment.delete_by_uuid(self.deployment['uuid'])
|
||||
mock_delete.assert_called_once_with(self.deployment['uuid'])
|
||||
objects.Deployment.delete_by_uuid(self.deployment["uuid"])
|
||||
mock_delete.assert_called_once_with(self.deployment["uuid"])
|
||||
|
||||
@mock.patch('rally.objects.deploy.db.deployment_update')
|
||||
@mock.patch('rally.objects.deploy.db.deployment_create')
|
||||
@mock.patch("rally.objects.deploy.db.deployment_update")
|
||||
@mock.patch("rally.objects.deploy.db.deployment_create")
|
||||
def test_update(self, mock_create, mock_update):
|
||||
mock_create.return_value = self.deployment
|
||||
mock_update.return_value = {'opt': 'val2'}
|
||||
deploy = objects.Deployment(opt='val1')
|
||||
deploy._update({'opt': 'val2'})
|
||||
mock_update.assert_called_once_with(self.deployment['uuid'],
|
||||
{'opt': 'val2'})
|
||||
self.assertEqual(deploy['opt'], 'val2')
|
||||
mock_update.return_value = {"opt": "val2"}
|
||||
deploy = objects.Deployment(opt="val1")
|
||||
deploy._update({"opt": "val2"})
|
||||
mock_update.assert_called_once_with(self.deployment["uuid"],
|
||||
{"opt": "val2"})
|
||||
self.assertEqual(deploy["opt"], "val2")
|
||||
|
||||
@mock.patch('rally.objects.deploy.db.deployment_update')
|
||||
@mock.patch("rally.objects.deploy.db.deployment_update")
|
||||
def test_update_status(self, mock_update):
|
||||
mock_update.return_value = self.deployment
|
||||
deploy = objects.Deployment(deployment=self.deployment)
|
||||
deploy.update_status(consts.DeployStatus.DEPLOY_FAILED)
|
||||
mock_update.assert_called_once_with(
|
||||
self.deployment['uuid'],
|
||||
{'status': consts.DeployStatus.DEPLOY_FAILED},
|
||||
self.deployment["uuid"],
|
||||
{"status": consts.DeployStatus.DEPLOY_FAILED},
|
||||
)
|
||||
|
||||
@mock.patch('rally.objects.deploy.db.deployment_update')
|
||||
@mock.patch("rally.objects.deploy.db.deployment_update")
|
||||
def test_update_name(self, mock_update):
|
||||
mock_update.return_value = self.deployment
|
||||
deploy = objects.Deployment(deployment=self.deployment)
|
||||
deploy.update_name('new_name')
|
||||
deploy.update_name("new_name")
|
||||
mock_update.assert_called_once_with(
|
||||
self.deployment['uuid'],
|
||||
{'name': 'new_name'},
|
||||
self.deployment["uuid"],
|
||||
{"name": "new_name"},
|
||||
)
|
||||
|
||||
@mock.patch('rally.objects.deploy.db.deployment_update')
|
||||
@mock.patch("rally.objects.deploy.db.deployment_update")
|
||||
def test_update_config(self, mock_update):
|
||||
mock_update.return_value = self.deployment
|
||||
deploy = objects.Deployment(deployment=self.deployment)
|
||||
deploy.update_config({'opt': 'val'})
|
||||
deploy.update_config({"opt": "val"})
|
||||
mock_update.assert_called_once_with(
|
||||
self.deployment['uuid'],
|
||||
{'config': {'opt': 'val'}},
|
||||
self.deployment["uuid"],
|
||||
{"config": {"opt": "val"}},
|
||||
)
|
||||
|
||||
@mock.patch('rally.objects.deploy.db.deployment_update')
|
||||
@mock.patch("rally.objects.deploy.db.deployment_update")
|
||||
def test_update_endpoints(self, mock_update):
|
||||
mock_update.return_value = self.deployment
|
||||
deploy = objects.Deployment(deployment=self.deployment)
|
||||
@ -141,7 +141,7 @@ class DeploymentTestCase(test.TestCase):
|
||||
"users": expected_users
|
||||
})
|
||||
|
||||
@mock.patch('rally.objects.deploy.db.deployment_update')
|
||||
@mock.patch("rally.objects.deploy.db.deployment_update")
|
||||
def test_update_empty_endpoints(self, mock_update):
|
||||
mock_update.return_value = self.deployment
|
||||
deploy = objects.Deployment(deployment=self.deployment)
|
||||
@ -149,55 +149,55 @@ class DeploymentTestCase(test.TestCase):
|
||||
mock_update.assert_called_once_with(self.deployment["uuid"],
|
||||
{"admin": {}, "users": []})
|
||||
|
||||
@mock.patch('rally.objects.deploy.db.resource_create')
|
||||
@mock.patch("rally.objects.deploy.db.resource_create")
|
||||
def test_add_resource(self, mock_create):
|
||||
mock_create.return_value = self.resource
|
||||
deploy = objects.Deployment(deployment=self.deployment)
|
||||
resource = deploy.add_resource('provider', type='some',
|
||||
info={'key': 'value'})
|
||||
self.assertEqual(resource['id'], self.resource['id'])
|
||||
resource = deploy.add_resource("provider", type="some",
|
||||
info={"key": "value"})
|
||||
self.assertEqual(resource["id"], self.resource["id"])
|
||||
mock_create.assert_called_once_with({
|
||||
'deployment_uuid': self.deployment['uuid'],
|
||||
'provider_name': 'provider',
|
||||
'type': 'some',
|
||||
'info': {'key': 'value'},
|
||||
"deployment_uuid": self.deployment["uuid"],
|
||||
"provider_name": "provider",
|
||||
"type": "some",
|
||||
"info": {"key": "value"},
|
||||
})
|
||||
|
||||
@mock.patch('rally.objects.task.db.resource_delete')
|
||||
@mock.patch("rally.objects.task.db.resource_delete")
|
||||
def test_delete(self, mock_delete):
|
||||
objects.Deployment.delete_resource(42)
|
||||
mock_delete.assert_called_once_with(42)
|
||||
|
||||
@mock.patch('rally.objects.task.db.resource_get_all')
|
||||
@mock.patch("rally.objects.task.db.resource_get_all")
|
||||
def test_get_resources(self, mock_get_all):
|
||||
mock_get_all.return_value = [self.resource]
|
||||
deploy = objects.Deployment(deployment=self.deployment)
|
||||
resources = deploy.get_resources(provider_name='provider', type='some')
|
||||
resources = deploy.get_resources(provider_name="provider", type="some")
|
||||
self.assertEqual(len(resources), 1)
|
||||
self.assertEqual(resources[0]['id'], self.resource['id'])
|
||||
self.assertEqual(resources[0]["id"], self.resource["id"])
|
||||
|
||||
@mock.patch('rally.objects.deploy.datetime.datetime')
|
||||
@mock.patch('rally.objects.deploy.db.deployment_update')
|
||||
@mock.patch("rally.objects.deploy.datetime.datetime")
|
||||
@mock.patch("rally.objects.deploy.db.deployment_update")
|
||||
def test_update_set_started(self, mock_update, mock_datetime):
|
||||
mock_datetime.now = mock.Mock(return_value='fake_time')
|
||||
mock_datetime.now = mock.Mock(return_value="fake_time")
|
||||
mock_update.return_value = self.deployment
|
||||
deploy = objects.Deployment(deployment=self.deployment)
|
||||
deploy.set_started()
|
||||
mock_update.assert_called_once_with(
|
||||
self.deployment['uuid'],
|
||||
{'started_at': 'fake_time',
|
||||
'status': consts.DeployStatus.DEPLOY_STARTED}
|
||||
self.deployment["uuid"],
|
||||
{"started_at": "fake_time",
|
||||
"status": consts.DeployStatus.DEPLOY_STARTED}
|
||||
)
|
||||
|
||||
@mock.patch('rally.objects.deploy.datetime.datetime')
|
||||
@mock.patch('rally.objects.deploy.db.deployment_update')
|
||||
@mock.patch("rally.objects.deploy.datetime.datetime")
|
||||
@mock.patch("rally.objects.deploy.db.deployment_update")
|
||||
def test_update_set_completed(self, mock_update, mock_datetime):
|
||||
mock_datetime.now = mock.Mock(return_value='fake_time')
|
||||
mock_datetime.now = mock.Mock(return_value="fake_time")
|
||||
mock_update.return_value = self.deployment
|
||||
deploy = objects.Deployment(deployment=self.deployment)
|
||||
deploy.set_completed()
|
||||
mock_update.assert_called_once_with(
|
||||
self.deployment['uuid'],
|
||||
{'completed_at': 'fake_time',
|
||||
'status': consts.DeployStatus.DEPLOY_FINISHED}
|
||||
self.deployment["uuid"],
|
||||
{"completed_at": "fake_time",
|
||||
"status": consts.DeployStatus.DEPLOY_FINISHED}
|
||||
)
|
||||
|
@ -28,59 +28,59 @@ class TaskTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(TaskTestCase, self).setUp()
|
||||
self.task = {
|
||||
'uuid': '00ef46a2-c5b8-4aea-a5ca-0f54a10cbca1',
|
||||
'status': consts.TaskStatus.INIT,
|
||||
'verification_log': '',
|
||||
"uuid": "00ef46a2-c5b8-4aea-a5ca-0f54a10cbca1",
|
||||
"status": consts.TaskStatus.INIT,
|
||||
"verification_log": "",
|
||||
}
|
||||
|
||||
@mock.patch('rally.objects.task.db.task_create')
|
||||
@mock.patch("rally.objects.task.db.task_create")
|
||||
def test_init_with_create(self, mock_create):
|
||||
mock_create.return_value = self.task
|
||||
task = objects.Task(status=consts.TaskStatus.FAILED)
|
||||
mock_create.assert_called_once_with({
|
||||
'status': consts.TaskStatus.FAILED})
|
||||
self.assertEqual(task['uuid'], self.task['uuid'])
|
||||
"status": consts.TaskStatus.FAILED})
|
||||
self.assertEqual(task["uuid"], self.task["uuid"])
|
||||
|
||||
@mock.patch('rally.objects.task.db.task_create')
|
||||
@mock.patch("rally.objects.task.db.task_create")
|
||||
def test_init_without_create(self, mock_create):
|
||||
task = objects.Task(task=self.task)
|
||||
self.assertFalse(mock_create.called)
|
||||
self.assertEqual(task['uuid'], self.task['uuid'])
|
||||
self.assertEqual(task["uuid"], self.task["uuid"])
|
||||
|
||||
@mock.patch('rally.objects.task.db.task_get')
|
||||
@mock.patch("rally.objects.task.db.task_get")
|
||||
def test_get(self, mock_get):
|
||||
mock_get.return_value = self.task
|
||||
task = objects.Task.get(self.task['uuid'])
|
||||
mock_get.assert_called_once_with(self.task['uuid'])
|
||||
self.assertEqual(task['uuid'], self.task['uuid'])
|
||||
task = objects.Task.get(self.task["uuid"])
|
||||
mock_get.assert_called_once_with(self.task["uuid"])
|
||||
self.assertEqual(task["uuid"], self.task["uuid"])
|
||||
|
||||
@mock.patch('rally.objects.task.db.task_delete')
|
||||
@mock.patch('rally.objects.task.db.task_create')
|
||||
@mock.patch("rally.objects.task.db.task_delete")
|
||||
@mock.patch("rally.objects.task.db.task_create")
|
||||
def test_create_and_delete(self, mock_create, mock_delete):
|
||||
mock_create.return_value = self.task
|
||||
task = objects.Task()
|
||||
task.delete()
|
||||
mock_delete.assert_called_once_with(self.task['uuid'], status=None)
|
||||
mock_delete.assert_called_once_with(self.task["uuid"], status=None)
|
||||
|
||||
@mock.patch('rally.objects.task.db.task_delete')
|
||||
@mock.patch('rally.objects.task.db.task_create')
|
||||
@mock.patch("rally.objects.task.db.task_delete")
|
||||
@mock.patch("rally.objects.task.db.task_create")
|
||||
def test_create_and_delete_status(self, mock_create, mock_delete):
|
||||
mock_create.return_value = self.task
|
||||
task = objects.Task()
|
||||
task.delete(status=consts.TaskStatus.FINISHED)
|
||||
mock_delete.assert_called_once_with(self.task['uuid'],
|
||||
mock_delete.assert_called_once_with(self.task["uuid"],
|
||||
status=consts.TaskStatus.FINISHED)
|
||||
|
||||
@mock.patch('rally.objects.task.db.task_delete')
|
||||
@mock.patch("rally.objects.task.db.task_delete")
|
||||
def test_delete_by_uuid(self, mock_delete):
|
||||
objects.Task.delete_by_uuid(self.task['uuid'])
|
||||
mock_delete.assert_called_once_with(self.task['uuid'], status=None)
|
||||
objects.Task.delete_by_uuid(self.task["uuid"])
|
||||
mock_delete.assert_called_once_with(self.task["uuid"], status=None)
|
||||
|
||||
@mock.patch('rally.objects.task.db.task_delete')
|
||||
@mock.patch("rally.objects.task.db.task_delete")
|
||||
def test_delete_by_uuid_status(self, mock_delete):
|
||||
objects.Task.delete_by_uuid(self.task['uuid'],
|
||||
objects.Task.delete_by_uuid(self.task["uuid"],
|
||||
consts.TaskStatus.FINISHED)
|
||||
mock_delete.assert_called_once_with(self.task['uuid'],
|
||||
mock_delete.assert_called_once_with(self.task["uuid"],
|
||||
status=consts.TaskStatus.FINISHED)
|
||||
|
||||
@mock.patch("rally.objects.task.db.task_list",
|
||||
@ -97,35 +97,35 @@ class TaskTestCase(test.TestCase):
|
||||
self.assertEqual(mock_db_task_list.return_value["uuis"],
|
||||
tasks[0]["uuid"])
|
||||
|
||||
@mock.patch('rally.objects.deploy.db.task_update')
|
||||
@mock.patch('rally.objects.task.db.task_create')
|
||||
@mock.patch("rally.objects.deploy.db.task_update")
|
||||
@mock.patch("rally.objects.task.db.task_create")
|
||||
def test_update(self, mock_create, mock_update):
|
||||
mock_create.return_value = self.task
|
||||
mock_update.return_value = {'opt': 'val2'}
|
||||
deploy = objects.Task(opt='val1')
|
||||
deploy._update({'opt': 'val2'})
|
||||
mock_update.assert_called_once_with(self.task['uuid'],
|
||||
{'opt': 'val2'})
|
||||
self.assertEqual(deploy['opt'], 'val2')
|
||||
mock_update.return_value = {"opt": "val2"}
|
||||
deploy = objects.Task(opt="val1")
|
||||
deploy._update({"opt": "val2"})
|
||||
mock_update.assert_called_once_with(self.task["uuid"],
|
||||
{"opt": "val2"})
|
||||
self.assertEqual(deploy["opt"], "val2")
|
||||
|
||||
@mock.patch('rally.objects.task.db.task_update')
|
||||
@mock.patch("rally.objects.task.db.task_update")
|
||||
def test_update_status(self, mock_update):
|
||||
mock_update.return_value = self.task
|
||||
task = objects.Task(task=self.task)
|
||||
task.update_status(consts.TaskStatus.FINISHED)
|
||||
mock_update.assert_called_once_with(
|
||||
self.task['uuid'],
|
||||
{'status': consts.TaskStatus.FINISHED},
|
||||
self.task["uuid"],
|
||||
{"status": consts.TaskStatus.FINISHED},
|
||||
)
|
||||
|
||||
@mock.patch('rally.objects.task.db.task_update')
|
||||
@mock.patch("rally.objects.task.db.task_update")
|
||||
def test_update_verification_log(self, mock_update):
|
||||
mock_update.return_value = self.task
|
||||
task = objects.Task(task=self.task)
|
||||
task.update_verification_log({"a": "fake"})
|
||||
mock_update.assert_called_once_with(
|
||||
self.task['uuid'],
|
||||
{'verification_log': json.dumps({"a": "fake"})}
|
||||
self.task["uuid"],
|
||||
{"verification_log": json.dumps({"a": "fake"})}
|
||||
)
|
||||
|
||||
@mock.patch("rally.objects.task.db.task_result_get_all_by_uuid",
|
||||
@ -136,19 +136,19 @@ class TaskTestCase(test.TestCase):
|
||||
mock_get.assert_called_once_with(self.task["uuid"])
|
||||
self.assertEqual(results, "foo_results")
|
||||
|
||||
@mock.patch('rally.objects.task.db.task_result_create')
|
||||
@mock.patch("rally.objects.task.db.task_result_create")
|
||||
def test_append_results(self, mock_append_results):
|
||||
task = objects.Task(task=self.task)
|
||||
task.append_results('opt', 'val')
|
||||
mock_append_results.assert_called_once_with(self.task['uuid'],
|
||||
'opt', 'val')
|
||||
task.append_results("opt", "val")
|
||||
mock_append_results.assert_called_once_with(self.task["uuid"],
|
||||
"opt", "val")
|
||||
|
||||
@mock.patch('rally.objects.task.db.task_update')
|
||||
@mock.patch("rally.objects.task.db.task_update")
|
||||
def test_set_failed(self, mock_update):
|
||||
mock_update.return_value = self.task
|
||||
task = objects.Task(task=self.task)
|
||||
task.set_failed()
|
||||
mock_update.assert_called_once_with(
|
||||
self.task['uuid'],
|
||||
{'status': consts.TaskStatus.FAILED, 'verification_log': '""'},
|
||||
self.task["uuid"],
|
||||
{"status": consts.TaskStatus.FAILED, "verification_log": '""'},
|
||||
)
|
||||
|
@ -24,67 +24,67 @@ class VerificationTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(VerificationTestCase, self).setUp()
|
||||
self.db_obj = {
|
||||
'id': 777,
|
||||
'uuid': 'test_uuid',
|
||||
'failures': 0, 'tests': 2, 'errors': 0, 'time': '0.54',
|
||||
'details': {
|
||||
'failures': 0, 'tests': 2, 'errors': 0, 'time': '0.54',
|
||||
'test_cases': [
|
||||
{'classname': 'foo.Test',
|
||||
'name': 'foo_test[gate,negative]',
|
||||
'time': '0.25'},
|
||||
{'classname': 'bar.Test',
|
||||
'name': 'bar_test[gate,negative]',
|
||||
'time': '0.29'}]}}
|
||||
"id": 777,
|
||||
"uuid": "test_uuid",
|
||||
"failures": 0, "tests": 2, "errors": 0, "time": "0.54",
|
||||
"details": {
|
||||
"failures": 0, "tests": 2, "errors": 0, "time": "0.54",
|
||||
"test_cases": [
|
||||
{"classname": "foo.Test",
|
||||
"name": "foo_test[gate,negative]",
|
||||
"time": "0.25"},
|
||||
{"classname": "bar.Test",
|
||||
"name": "bar_test[gate,negative]",
|
||||
"time": "0.29"}]}}
|
||||
|
||||
@mock.patch('rally.objects.verification.db.verification_create')
|
||||
@mock.patch("rally.objects.verification.db.verification_create")
|
||||
def test_init_with_create(self, mock_create):
|
||||
objects.Verification(deployment_uuid='some_deployment_uuid')
|
||||
mock_create.assert_called_once_with('some_deployment_uuid')
|
||||
objects.Verification(deployment_uuid="some_deployment_uuid")
|
||||
mock_create.assert_called_once_with("some_deployment_uuid")
|
||||
|
||||
@mock.patch('rally.objects.verification.db.verification_create')
|
||||
@mock.patch("rally.objects.verification.db.verification_create")
|
||||
def test_init_without_create(self, mock_create):
|
||||
verification = objects.Verification(db_object=self.db_obj)
|
||||
|
||||
self.assertEqual(0, mock_create.call_count)
|
||||
self.assertEqual(self.db_obj['failures'], verification.failures)
|
||||
self.assertEqual(self.db_obj['tests'], verification.tests)
|
||||
self.assertEqual(self.db_obj['errors'], verification.errors)
|
||||
self.assertEqual(self.db_obj['time'], verification.time)
|
||||
self.assertEqual(self.db_obj["failures"], verification.failures)
|
||||
self.assertEqual(self.db_obj["tests"], verification.tests)
|
||||
self.assertEqual(self.db_obj["errors"], verification.errors)
|
||||
self.assertEqual(self.db_obj["time"], verification.time)
|
||||
|
||||
@mock.patch('rally.objects.verification.db.verification_get')
|
||||
@mock.patch("rally.objects.verification.db.verification_get")
|
||||
def test_get(self, mock_get):
|
||||
objects.Verification.get(self.db_obj['id'])
|
||||
mock_get.assert_called_once_with(self.db_obj['id'])
|
||||
objects.Verification.get(self.db_obj["id"])
|
||||
mock_get.assert_called_once_with(self.db_obj["id"])
|
||||
|
||||
@mock.patch('rally.objects.verification.db.verification_delete')
|
||||
@mock.patch('rally.objects.verification.db.verification_create')
|
||||
@mock.patch("rally.objects.verification.db.verification_delete")
|
||||
@mock.patch("rally.objects.verification.db.verification_create")
|
||||
def test_create_and_delete(self, mock_create, mock_delete):
|
||||
verification = objects.Verification(db_object=self.db_obj)
|
||||
verification.delete()
|
||||
mock_delete.assert_called_once_with(self.db_obj['uuid'])
|
||||
mock_delete.assert_called_once_with(self.db_obj["uuid"])
|
||||
|
||||
@mock.patch('rally.objects.verification.db.verification_update')
|
||||
@mock.patch("rally.objects.verification.db.verification_update")
|
||||
def test_set_failed(self, mock_update):
|
||||
mock_update.return_value = self.db_obj
|
||||
verification = objects.Verification(db_object=self.db_obj)
|
||||
verification.set_failed()
|
||||
mock_update.assert_called_once_with(self.db_obj['uuid'],
|
||||
{'status': 'failed'})
|
||||
mock_update.assert_called_once_with(self.db_obj["uuid"],
|
||||
{"status": "failed"})
|
||||
|
||||
@mock.patch('rally.objects.verification.db.verification_result_create')
|
||||
@mock.patch('rally.objects.verification.db.verification_update')
|
||||
@mock.patch("rally.objects.verification.db.verification_result_create")
|
||||
@mock.patch("rally.objects.verification.db.verification_update")
|
||||
def test_finish_verification(self, mock_update, mock_create):
|
||||
verification = objects.Verification(db_object=self.db_obj)
|
||||
fake_results = fakes.get_fake_test_case()
|
||||
verification.finish_verification(
|
||||
fake_results['total'],
|
||||
fake_results['test_cases'])
|
||||
fake_results["total"],
|
||||
fake_results["test_cases"])
|
||||
|
||||
expected_values = {'status': 'finished'}
|
||||
expected_values.update(fake_results['total'])
|
||||
mock_update.assert_called_with(self.db_obj['uuid'], expected_values)
|
||||
expected_values = {"status": "finished"}
|
||||
expected_values.update(fake_results["total"])
|
||||
mock_update.assert_called_with(self.db_obj["uuid"], expected_values)
|
||||
|
||||
expected_data = fake_results['total'].copy()
|
||||
expected_data['test_cases'] = fake_results['test_cases']
|
||||
expected_data = fake_results["total"].copy()
|
||||
expected_data["test_cases"] = fake_results["test_cases"]
|
||||
mock_create.assert_called_once_with(verification.uuid, expected_data)
|
||||
|
@ -94,7 +94,7 @@ class TaskAPITestCase(test.TestCase):
|
||||
self.assertRaises(TypeError, api.Task.render_template, "{{a}}")
|
||||
|
||||
@mock.patch("rally.objects.Deployment.get",
|
||||
return_value={'uuid': 'b0d9cd6c-2c94-4417-a238-35c7019d0257'})
|
||||
return_value={"uuid": "b0d9cd6c-2c94-4417-a238-35c7019d0257"})
|
||||
@mock.patch("rally.objects.Task")
|
||||
def test_create(self, mock_task, mock_d_get):
|
||||
tag = "a"
|
||||
@ -207,7 +207,7 @@ class DeploymentAPITestCase(BaseDeploymentTestCase):
|
||||
@mock.patch("rally.objects.deploy.db.deployment_update")
|
||||
@mock.patch("rally.objects.deploy.db.deployment_create")
|
||||
@mock.patch("rally.deploy.engine.EngineFactory.validate",
|
||||
side_effect=jsonschema.ValidationError('ValidationError'))
|
||||
side_effect=jsonschema.ValidationError("ValidationError"))
|
||||
def test_create_validation_error(self, mock_validate, mock_create,
|
||||
mock_update):
|
||||
mock_create.return_value = self.deployment
|
||||
@ -216,12 +216,12 @@ class DeploymentAPITestCase(BaseDeploymentTestCase):
|
||||
self.deployment_config, "fake_deployment")
|
||||
mock_update.assert_called_once_with(
|
||||
self.deployment_uuid,
|
||||
{'status': consts.DeployStatus.DEPLOY_FAILED})
|
||||
{"status": consts.DeployStatus.DEPLOY_FAILED})
|
||||
|
||||
@mock.patch("rally.api.LOG")
|
||||
@mock.patch("rally.objects.deploy.db.deployment_create",
|
||||
side_effect=exceptions.DeploymentNameExists(
|
||||
deployment='fake_deploy'))
|
||||
deployment="fake_deploy"))
|
||||
def test_create_duplication_error(self, mock_d_create, mock_log):
|
||||
self.assertRaises(exceptions.DeploymentNameExists,
|
||||
api.Deployment.create, self.deployment_config,
|
||||
|
@ -16,27 +16,27 @@
|
||||
|
||||
def get_fake_test_case():
|
||||
return {
|
||||
'total': {
|
||||
'failures': 1,
|
||||
'tests': 2,
|
||||
'errors': 0,
|
||||
'time': 1.412},
|
||||
'test_cases': {
|
||||
'fake.failed.TestCase.with_StringException[gate,negative]': {
|
||||
'name':
|
||||
'fake.failed.TestCase.with_StringException[gate,negative]',
|
||||
'failure': {
|
||||
'type': 'testtools.testresult.real._StringException',
|
||||
'log':
|
||||
('_StringException: Empty attachments:\nOops...There '
|
||||
'was supposed to be fake traceback, but it is not.\n')
|
||||
"total": {
|
||||
"failures": 1,
|
||||
"tests": 2,
|
||||
"errors": 0,
|
||||
"time": 1.412},
|
||||
"test_cases": {
|
||||
"fake.failed.TestCase.with_StringException[gate,negative]": {
|
||||
"name":
|
||||
"fake.failed.TestCase.with_StringException[gate,negative]",
|
||||
"failure": {
|
||||
"type": "testtools.testresult.real._StringException",
|
||||
"log":
|
||||
("_StringException: Empty attachments:\nOops...There "
|
||||
"was supposed to be fake traceback, but it is not.\n")
|
||||
},
|
||||
'time': 0.706,
|
||||
'status': 'FAIL'},
|
||||
'fake.successful.TestCase.fake_test[gate,negative]': {
|
||||
'name': 'fake.successful.TestCase.fake_test[gate,negative]',
|
||||
'time': 0.706,
|
||||
'status': 'OK'
|
||||
"time": 0.706,
|
||||
"status": "FAIL"},
|
||||
"fake.successful.TestCase.fake_test[gate,negative]": {
|
||||
"name": "fake.successful.TestCase.fake_test[gate,negative]",
|
||||
"time": 0.706,
|
||||
"status": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ from tests.unit import test
|
||||
class Compare2HtmlTestCase(test.TestCase):
|
||||
|
||||
def test_main(self):
|
||||
results = [{'val2': 0.0111, 'field': u'time', 'val1': 0.0222,
|
||||
'type': 'CHANGED', 'test_name': u'test.one'},
|
||||
{'val2': 0.111, 'field': u'time', 'val1': 0.222,
|
||||
'type': 'CHANGED', 'test_name': u'test.two'},
|
||||
{'val2': 1.11, 'field': u'time', 'val1': 2.22,
|
||||
'type': 'CHANGED', 'test_name': u'test.three'}]
|
||||
results = [{"val2": 0.0111, "field": u"time", "val1": 0.0222,
|
||||
"type": "CHANGED", "test_name": u"test.one"},
|
||||
{"val2": 0.111, "field": u"time", "val1": 0.222,
|
||||
"type": "CHANGED", "test_name": u"test.two"},
|
||||
{"val2": 1.11, "field": u"time", "val1": 2.22,
|
||||
"type": "CHANGED", "test_name": u"test.three"}]
|
||||
|
||||
fake_kw = {"heading":
|
||||
{"title": compare2html.__title__,
|
||||
@ -34,6 +34,6 @@ class Compare2HtmlTestCase(test.TestCase):
|
||||
"generator": "compare2html %s" % compare2html.__version__,
|
||||
"results": results}
|
||||
|
||||
with mock.patch('mako.template.Template') as mock_mako:
|
||||
with mock.patch("mako.template.Template") as mock_mako:
|
||||
compare2html.create_report(results)
|
||||
mock_mako().render.assert_called_once_with(**fake_kw)
|
||||
|
@ -297,14 +297,14 @@ class ConfigTestCase(test.TestCase):
|
||||
self.assertEqual(self.conf_generator.conf.get(
|
||||
"service_available", "horizon"), "True")
|
||||
|
||||
@mock.patch('six.moves.builtins.open', side_effect=mock.mock_open(),
|
||||
@mock.patch("six.moves.builtins.open", side_effect=mock.mock_open(),
|
||||
create=True)
|
||||
def test_write_config(self, mock_open):
|
||||
self.conf_generator.conf = mock.Mock()
|
||||
file_name = '/path/to/fake/conf'
|
||||
file_name = "/path/to/fake/conf"
|
||||
|
||||
self.conf_generator.write_config(file_name)
|
||||
|
||||
mock_open.assert_called_once_with(file_name, 'w+')
|
||||
mock_open.assert_called_once_with(file_name, "w+")
|
||||
self.conf_generator.conf.write.assert_called_once_with(
|
||||
mock_open.side_effect())
|
||||
|
@ -16,74 +16,74 @@ from tests.unit import test
|
||||
class DiffTestCase(test.TestCase):
|
||||
|
||||
def test_main(self):
|
||||
results1 = {'test.NONE': {'name': 'test.NONE',
|
||||
'output': 'test.NONE',
|
||||
'status': 'SKIPPED',
|
||||
'time': 0.000},
|
||||
'test.zerofive': {'name': 'test.zerofive',
|
||||
'output': 'test.zerofive',
|
||||
'status': 'FAILED',
|
||||
'time': 0.05},
|
||||
'test.one': {'name': 'test.one',
|
||||
'output': 'test.one',
|
||||
'status': 'OK',
|
||||
'time': 0.111},
|
||||
'test.two': {'name': 'test.two',
|
||||
'output': 'test.two',
|
||||
'status': 'OK',
|
||||
'time': 0.222},
|
||||
'test.three': {'name': 'test.three',
|
||||
'output': 'test.three',
|
||||
'status': 'FAILED',
|
||||
'time': 0.333},
|
||||
'test.four': {'name': 'test.four',
|
||||
'output': 'test.four',
|
||||
'status': 'OK',
|
||||
'time': 0.444},
|
||||
'test.five': {'name': 'test.five',
|
||||
'output': 'test.five',
|
||||
'status': 'OK',
|
||||
'time': 0.555}
|
||||
results1 = {"test.NONE": {"name": "test.NONE",
|
||||
"output": "test.NONE",
|
||||
"status": "SKIPPED",
|
||||
"time": 0.000},
|
||||
"test.zerofive": {"name": "test.zerofive",
|
||||
"output": "test.zerofive",
|
||||
"status": "FAILED",
|
||||
"time": 0.05},
|
||||
"test.one": {"name": "test.one",
|
||||
"output": "test.one",
|
||||
"status": "OK",
|
||||
"time": 0.111},
|
||||
"test.two": {"name": "test.two",
|
||||
"output": "test.two",
|
||||
"status": "OK",
|
||||
"time": 0.222},
|
||||
"test.three": {"name": "test.three",
|
||||
"output": "test.three",
|
||||
"status": "FAILED",
|
||||
"time": 0.333},
|
||||
"test.four": {"name": "test.four",
|
||||
"output": "test.four",
|
||||
"status": "OK",
|
||||
"time": 0.444},
|
||||
"test.five": {"name": "test.five",
|
||||
"output": "test.five",
|
||||
"status": "OK",
|
||||
"time": 0.555}
|
||||
}
|
||||
|
||||
results2 = {'test.one': {'name': 'test.one',
|
||||
'output': 'test.one',
|
||||
'status': 'FAIL',
|
||||
'time': 0.1111},
|
||||
'test.two': {'name': 'test.two',
|
||||
'output': 'test.two',
|
||||
'status': 'OK',
|
||||
'time': 0.222},
|
||||
'test.three': {'name': 'test.three',
|
||||
'output': 'test.three',
|
||||
'status': 'OK',
|
||||
'time': 0.3333},
|
||||
'test.four': {'name': 'test.four',
|
||||
'output': 'test.four',
|
||||
'status': 'FAIL',
|
||||
'time': 0.4444},
|
||||
'test.five': {'name': 'test.five',
|
||||
'output': 'test.five',
|
||||
'status': 'OK',
|
||||
'time': 0.555},
|
||||
'test.six': {'name': 'test.six',
|
||||
'output': 'test.six',
|
||||
'status': 'OK',
|
||||
'time': 0.666},
|
||||
'test.seven': {'name': 'test.seven',
|
||||
'output': 'test.seven',
|
||||
'status': 'OK',
|
||||
'time': 0.777}
|
||||
results2 = {"test.one": {"name": "test.one",
|
||||
"output": "test.one",
|
||||
"status": "FAIL",
|
||||
"time": 0.1111},
|
||||
"test.two": {"name": "test.two",
|
||||
"output": "test.two",
|
||||
"status": "OK",
|
||||
"time": 0.222},
|
||||
"test.three": {"name": "test.three",
|
||||
"output": "test.three",
|
||||
"status": "OK",
|
||||
"time": 0.3333},
|
||||
"test.four": {"name": "test.four",
|
||||
"output": "test.four",
|
||||
"status": "FAIL",
|
||||
"time": 0.4444},
|
||||
"test.five": {"name": "test.five",
|
||||
"output": "test.five",
|
||||
"status": "OK",
|
||||
"time": 0.555},
|
||||
"test.six": {"name": "test.six",
|
||||
"output": "test.six",
|
||||
"status": "OK",
|
||||
"time": 0.666},
|
||||
"test.seven": {"name": "test.seven",
|
||||
"output": "test.seven",
|
||||
"status": "OK",
|
||||
"time": 0.777}
|
||||
}
|
||||
|
||||
diff_ = diff.Diff(results1, results2, 0)
|
||||
assert len(diff_.diffs) == 10
|
||||
assert len([test for test in diff_.diffs
|
||||
if test['type'] == 'removed_test']) == 2
|
||||
if test["type"] == "removed_test"]) == 2
|
||||
assert len([test for test in diff_.diffs
|
||||
if test['type'] == 'new_test']) == 2
|
||||
if test["type"] == "new_test"]) == 2
|
||||
assert len([test for test in diff_.diffs
|
||||
if test['type'] == 'value_changed']) == 6
|
||||
assert diff_.to_csv() != ''
|
||||
assert diff_.to_html() != ''
|
||||
assert diff_.to_json() != ''
|
||||
if test["type"] == "value_changed"]) == 6
|
||||
assert diff_.to_csv() != ""
|
||||
assert diff_.to_html() != ""
|
||||
assert diff_.to_json() != ""
|
||||
|
@ -34,7 +34,7 @@ TEMPEST_PATH = "rally.verification.tempest"
|
||||
class BaseTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(BaseTestCase, self).setUp()
|
||||
self.verifier = tempest.Tempest('fake_deployment_id',
|
||||
self.verifier = tempest.Tempest("fake_deployment_id",
|
||||
verification=mock.MagicMock())
|
||||
|
||||
self.verifier._path = "/tmp"
|
||||
@ -135,24 +135,24 @@ class TempestUtilsTestCase(BaseTestCase):
|
||||
mock_isdir.assert_called_once_with(
|
||||
self.verifier.path(".testrepository"))
|
||||
mock_sp.assert_called_once_with(
|
||||
'%s testr init' % self.verifier.venv_wrapper, shell=True,
|
||||
"%s testr init" % self.verifier.venv_wrapper, shell=True,
|
||||
cwd=self.verifier.path(), stderr=subprocess.STDOUT)
|
||||
|
||||
@mock.patch.object(subunit2json, 'main')
|
||||
@mock.patch('os.path.isfile', return_value=False)
|
||||
@mock.patch.object(subunit2json, "main")
|
||||
@mock.patch("os.path.isfile", return_value=False)
|
||||
def test__save_results_without_log_file(self, mock_isfile, mock_parse):
|
||||
|
||||
self.verifier._save_results()
|
||||
mock_isfile.assert_called_once_with(self.verifier.log_file_raw)
|
||||
self.assertEqual(0, mock_parse.call_count)
|
||||
|
||||
@mock.patch('os.path.isfile', return_value=True)
|
||||
@mock.patch("os.path.isfile", return_value=True)
|
||||
def test__save_results_with_log_file(self, mock_isfile):
|
||||
with mock.patch.object(subunit2json, 'main') as mock_main:
|
||||
data = {'total': True, 'test_cases': True}
|
||||
with mock.patch.object(subunit2json, "main") as mock_main:
|
||||
data = {"total": True, "test_cases": True}
|
||||
mock_main.return_value = jsonutils.dumps(data)
|
||||
self.verifier.log_file_raw = os.path.join(
|
||||
os.path.dirname(__file__), 'subunit.stream')
|
||||
os.path.dirname(__file__), "subunit.stream")
|
||||
self.verifier._save_results()
|
||||
mock_isfile.assert_called_once_with(self.verifier.log_file_raw)
|
||||
mock_main.assert_called_once_with(
|
||||
@ -168,7 +168,7 @@ class TempestInstallAndUninstallTestCase(BaseTestCase):
|
||||
def test__clone_successful(self, mock_sp):
|
||||
self.verifier._clone()
|
||||
mock_sp.assert_called_once_with(
|
||||
['git', 'clone', 'https://github.com/openstack/tempest',
|
||||
["git", "clone", "https://github.com/openstack/tempest",
|
||||
tempest.Tempest.base_repo])
|
||||
|
||||
@mock.patch(TEMPEST_PATH + ".tempest.subprocess.check_call")
|
||||
@ -178,7 +178,7 @@ class TempestInstallAndUninstallTestCase(BaseTestCase):
|
||||
|
||||
self.assertRaises(subprocess.CalledProcessError, self.verifier._clone)
|
||||
mock_sp.assert_called_once_with(
|
||||
['git', 'clone', 'https://github.com/openstack/tempest',
|
||||
["git", "clone", "https://github.com/openstack/tempest",
|
||||
tempest.Tempest.base_repo])
|
||||
|
||||
@mock.patch(TEMPEST_PATH + ".tempest.Tempest._initialize_testr")
|
||||
|
Loading…
Reference in New Issue
Block a user