Fix order of arguments in assertEqual

Some tests used incorrect order assertEqual(observed, expected).
The correct order expected by testtools is
assertEqual(expected, observed).

Change-Id: I5ac8602b47a747e77dc8afd579d4e280b3ed894f
Partial-Bug: #1259292
This commit is contained in:
hardik 2015-09-24 16:43:48 +05:30
parent 54a683356c
commit 199dca0aea
13 changed files with 150 additions and 150 deletions

View File

@ -23,4 +23,4 @@ class EchoActionTest(base.BaseTest):
expected = "my output"
action = std.EchoAction(expected)
self.assertEqual(action.run(), expected)
self.assertEqual(expected, action.run())

View File

@ -95,9 +95,9 @@ class SendEmailActionTest(base.BaseTest):
self.assertTrue(sendmail.called, "should call sendmail")
self.assertEqual(
sendmail.call_args[1]['from_addr'], self.from_addr)
self.from_addr, sendmail.call_args[1]['from_addr'])
self.assertEqual(
sendmail.call_args[1]['to_addrs'], self.to_addrs_str)
self.to_addrs_str, sendmail.call_args[1]['to_addrs'])
message = parser.Parser().parsestr(sendmail.call_args[1]['msg'])

View File

@ -99,14 +99,14 @@ class TestActionsController(base.FunctionalTest):
def test_get(self):
resp = self.app.get('/v2/actions/my_action')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual(ACTION, resp.json)
@mock.patch.object(db_api, "get_action_definition", MOCK_NOT_FOUND)
def test_get_not_found(self):
resp = self.app.get('/v2/actions/my_action', expect_errors=True)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
@mock.patch.object(db_api, "get_action_definition", MOCK_ACTION)
@mock.patch.object(
@ -119,7 +119,7 @@ class TestActionsController(base.FunctionalTest):
headers={'Content-Type': 'text/plain'}
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual({"actions": [UPDATED_ACTION]}, resp.json)
@ -135,7 +135,7 @@ class TestActionsController(base.FunctionalTest):
headers={'Content-Type': 'text/plain'}
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual({"actions": [UPDATED_ACTION]}, resp.json)
@ -163,7 +163,7 @@ class TestActionsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn('Attempt to modify a system action: std.echo',
resp.text)
@ -177,7 +177,7 @@ class TestActionsController(base.FunctionalTest):
headers={'Content-Type': 'text/plain'}
)
self.assertEqual(resp.status_int, 201)
self.assertEqual(201, resp.status_int)
self.assertEqual({"actions": [ACTION]}, resp.json)
self.assertEqual(1, mock_mtd.call_count)
@ -201,7 +201,7 @@ class TestActionsController(base.FunctionalTest):
headers={'Content-Type': 'text/plain'}
)
self.assertEqual(resp.status_int, 201)
self.assertEqual(201, resp.status_int)
self.assertEqual({"actions": [ACTION]}, resp.json)
self.assertEqual("public", mock_mtd.call_args[0][0]['scope'])
@ -217,7 +217,7 @@ class TestActionsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Scope must be one of the following", resp.text)
@mock.patch.object(db_api, "create_action_definition", MOCK_DUPLICATE)
@ -229,26 +229,26 @@ class TestActionsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 409)
self.assertEqual(409, resp.status_int)
@mock.patch.object(db_api, "get_action_definition", MOCK_ACTION)
@mock.patch.object(db_api, "delete_action_definition", MOCK_DELETE)
def test_delete(self):
resp = self.app.delete('/v2/actions/my_action')
self.assertEqual(resp.status_int, 204)
self.assertEqual(204, resp.status_int)
@mock.patch.object(db_api, "delete_action_definition", MOCK_NOT_FOUND)
def test_delete_not_found(self):
resp = self.app.delete('/v2/actions/my_action', expect_errors=True)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
@mock.patch.object(db_api, "get_action_definition", MOCK_SYSTEM_ACTION)
def test_delete_system(self):
resp = self.app.delete('/v2/actions/std.echo', expect_errors=True)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn('Attempt to delete a system action: std.echo',
resp.json['faultstring'])
@ -256,27 +256,27 @@ class TestActionsController(base.FunctionalTest):
def test_get_all(self):
resp = self.app.get('/v2/actions')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(len(resp.json['actions']), 1)
self.assertEqual(1, len(resp.json['actions']))
self.assertDictEqual(ACTION, resp.json['actions'][0])
@mock.patch.object(db_api, "get_action_definitions", MOCK_EMPTY)
def test_get_all_empty(self):
resp = self.app.get('/v2/actions')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(len(resp.json['actions']), 0)
self.assertEqual(0, len(resp.json['actions']))
@mock.patch.object(db_api, "get_action_definitions", MOCK_ACTIONS)
def test_get_all_pagination(self):
resp = self.app.get(
'/v2/actions?limit=1&sort_keys=id,name')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertIn('next', resp.json)
self.assertEqual(len(resp.json['actions']), 1)
self.assertEqual(1, len(resp.json['actions']))
self.assertDictEqual(ACTION, resp.json['actions'][0])
param_dict = utils.get_dict_from_string(
@ -301,7 +301,7 @@ class TestActionsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Limit must be positive", resp.body)
@ -311,7 +311,7 @@ class TestActionsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("unable to convert to int", resp.body)
@ -321,7 +321,7 @@ class TestActionsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn(
"Length of sort_keys must be equal or greater than sort_dirs",
@ -334,6 +334,6 @@ class TestActionsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Unknown sort direction", resp.body)

View File

@ -79,7 +79,7 @@ class TestCronTriggerController(base.FunctionalTest):
def test_get(self):
resp = self.app.get('/v2/cron_triggers/my_cron_trigger')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual(TRIGGER, resp.json)
@mock.patch.object(db_api, "get_cron_trigger", MOCK_NOT_FOUND)
@ -89,7 +89,7 @@ class TestCronTriggerController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
@mock.patch.object(db_api, "get_workflow_definition", MOCK_WF)
@mock.patch.object(db_api, "create_cron_trigger")
@ -98,7 +98,7 @@ class TestCronTriggerController(base.FunctionalTest):
resp = self.app.post_json('/v2/cron_triggers', TRIGGER)
self.assertEqual(resp.status_int, 201)
self.assertEqual(201, resp.status_int)
self.assertDictEqual(TRIGGER, resp.json)
self.assertEqual(1, mock_mtd.call_count)
@ -115,7 +115,7 @@ class TestCronTriggerController(base.FunctionalTest):
'/v2/cron_triggers', TRIGGER, expect_errors=True
)
self.assertEqual(resp.status_int, 409)
self.assertEqual(409, resp.status_int)
@mock.patch.object(db_api, "get_workflow_definition", MOCK_WF)
@mock.patch.object(db_api, "create_cron_trigger", MOCK_DUPLICATE)
@ -127,14 +127,14 @@ class TestCronTriggerController(base.FunctionalTest):
'/v2/cron_triggers', trig, expect_errors=True
)
self.assertEqual(resp.status_int, 409)
self.assertEqual(409, resp.status_int)
@mock.patch.object(db_api, "get_cron_trigger", MOCK_TRIGGER)
@mock.patch.object(db_api, "delete_cron_trigger", MOCK_DELETE)
def test_delete(self):
resp = self.app.delete('/v2/cron_triggers/my_cron_trigger')
self.assertEqual(resp.status_int, 204)
self.assertEqual(204, resp.status_int)
@mock.patch.object(db_api, "delete_cron_trigger", MOCK_NOT_FOUND)
def test_delete_not_found(self):
@ -143,21 +143,21 @@ class TestCronTriggerController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
@mock.patch.object(db_api, "get_cron_triggers", MOCK_TRIGGERS)
def test_get_all(self):
resp = self.app.get('/v2/cron_triggers')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(len(resp.json['cron_triggers']), 1)
self.assertEqual(1, len(resp.json['cron_triggers']))
self.assertDictEqual(TRIGGER, resp.json['cron_triggers'][0])
@mock.patch.object(db_api, "get_cron_triggers", MOCK_EMPTY)
def test_get_all_empty(self):
resp = self.app.get('/v2/cron_triggers')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(len(resp.json['cron_triggers']), 0)
self.assertEqual(0, len(resp.json['cron_triggers']))

View File

@ -79,14 +79,14 @@ class TestExecutionsController(base.FunctionalTest):
self.maxDiff = None
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual(WF_EX_JSON_WITH_DESC, resp.json)
@mock.patch.object(db_api, 'get_workflow_execution', MOCK_NOT_FOUND)
def test_get_not_found(self):
resp = self.app.get('/v2/executions/123', expect_errors=True)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
@mock.patch.object(
db_api,
@ -101,7 +101,7 @@ class TestExecutionsController(base.FunctionalTest):
UPDATED_WF_EX_WITH_DESC = copy.copy(UPDATED_WF_EX_JSON)
UPDATED_WF_EX_WITH_DESC['description'] = 'execution description.'
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual(UPDATED_WF_EX_WITH_DESC, resp.json)
@mock.patch.object(
@ -124,7 +124,7 @@ class TestExecutionsController(base.FunctionalTest):
update_exec['description'] = "execution description."
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual(update_exec, resp.json)
mock_pw.assert_called_once_with('123', 'ERROR', "Force")
@ -149,7 +149,7 @@ class TestExecutionsController(base.FunctionalTest):
update_exec['description'] = 'execution description.'
update_exec['state_info'] = None
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual(update_exec, resp.json)
mock_pw.assert_called_once_with('123', 'ERROR', None)
@ -161,7 +161,7 @@ class TestExecutionsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
def test_put_both_state_and_description(self):
self.assertRaises(
@ -179,7 +179,7 @@ class TestExecutionsController(base.FunctionalTest):
resp = self.app.put_json('/v2/executions/123', update_params)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
mock_ensure.assert_called_once_with('123')
mock_update.assert_called_once_with('123', update_params)
@ -189,7 +189,7 @@ class TestExecutionsController(base.FunctionalTest):
resp = self.app.post_json('/v2/executions', WF_EX_JSON_WITH_DESC)
self.assertEqual(resp.status_int, 201)
self.assertEqual(201, resp.status_int)
self.assertDictEqual(WF_EX_JSON_WITH_DESC, resp.json)
exec_dict = WF_EX_JSON_WITH_DESC
@ -216,30 +216,30 @@ class TestExecutionsController(base.FunctionalTest):
def test_delete(self):
resp = self.app.delete('/v2/executions/123')
self.assertEqual(resp.status_int, 204)
self.assertEqual(204, resp.status_int)
@mock.patch.object(db_api, 'delete_workflow_execution', MOCK_NOT_FOUND)
def test_delete_not_found(self):
resp = self.app.delete('/v2/executions/123', expect_errors=True)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
@mock.patch.object(db_api, 'get_workflow_executions', MOCK_WF_EXECUTIONS)
def test_get_all(self):
resp = self.app.get('/v2/executions')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(len(resp.json['executions']), 1)
self.assertEqual(1, len(resp.json['executions']))
self.assertDictEqual(WF_EX_JSON_WITH_DESC, resp.json['executions'][0])
@mock.patch.object(db_api, 'get_workflow_executions', MOCK_EMPTY)
def test_get_all_empty(self):
resp = self.app.get('/v2/executions')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(len(resp.json['executions']), 0)
self.assertEqual(0, len(resp.json['executions']))
@mock.patch.object(db_api, "get_workflow_executions", MOCK_WF_EXECUTIONS)
def test_get_all_pagination(self):
@ -247,9 +247,9 @@ class TestExecutionsController(base.FunctionalTest):
'/v2/executions?limit=1&sort_keys=id,workflow_name'
'&sort_dirs=asc,desc')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertIn('next', resp.json)
self.assertEqual(len(resp.json['executions']), 1)
self.assertEqual(1, len(resp.json['executions']))
self.assertDictEqual(WF_EX_JSON_WITH_DESC, resp.json['executions'][0])
param_dict = utils.get_dict_from_string(
@ -272,7 +272,7 @@ class TestExecutionsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Limit must be positive", resp.body)
@ -282,7 +282,7 @@ class TestExecutionsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("unable to convert to int", resp.body)
@ -292,7 +292,7 @@ class TestExecutionsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn(
"Length of sort_keys must be equal or greater than sort_dirs",
@ -305,6 +305,6 @@ class TestExecutionsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Unknown sort direction", resp.body)

View File

@ -23,21 +23,21 @@ class TestRootController(base.FunctionalTest):
def test_index(self):
resp = self.app.get('/', headers={'Accept': 'application/json'})
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
data = jsonutils.loads(resp.body.decode())
self.assertEqual(data[0]['id'], 'v2.0')
self.assertEqual(data[0]['status'], 'CURRENT')
self.assertEqual('v2.0', data[0]['id'])
self.assertEqual('CURRENT', data[0]['status'])
self.assertEqual(
data[0]['link'],
{'href': 'http://localhost/v2', 'target': 'v2'}
{'href': 'http://localhost/v2', 'target': 'v2'},
data[0]['link']
)
def test_v2_root(self):
resp = self.app.get('/v2/', headers={'Accept': 'application/json'})
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
data = jsonutils.loads(resp.body.decode())
@ -51,21 +51,21 @@ class TestRootControllerWithAuth(test_auth.TestKeystoneMiddleware):
def test_index(self):
resp = self.app.get('/', headers={'Accept': 'application/json'})
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
data = jsonutils.loads(resp.body.decode())
self.assertEqual(data[0]['id'], 'v2.0')
self.assertEqual(data[0]['status'], 'CURRENT')
self.assertEqual('v2.0', data[0]['id'])
self.assertEqual('CURRENT', data[0]['status'])
self.assertEqual(
data[0]['link'],
{'href': 'http://localhost/v2', 'target': 'v2'}
{'href': 'http://localhost/v2', 'target': 'v2'},
data[0]['link']
)
def test_v2_root(self):
resp = self.app.get('/v2/', headers={'Accept': 'application/json'})
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
data = jsonutils.loads(resp.body.decode())

View File

@ -33,9 +33,9 @@ class TestServicesController(base.FunctionalTest):
resp = self.app.get('/v2/services')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(len(resp.json['services']), 1)
self.assertEqual(1, len(resp.json['services']))
srv_ret = [{"name": "service1", "type": "api_group"}]
self.assertItemsEqual(srv_ret, resp.json['services'])

View File

@ -142,31 +142,31 @@ class TestTasksController(base.FunctionalTest):
def test_get(self):
resp = self.app.get('/v2/tasks/123')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual(TASK, resp.json)
@mock.patch.object(db_api, 'get_task_execution', MOCK_NOT_FOUND)
def test_get_not_found(self):
resp = self.app.get('/v2/tasks/123', expect_errors=True)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
@mock.patch.object(db_api, 'get_task_executions', MOCK_TASKS)
def test_get_all(self):
resp = self.app.get('/v2/tasks')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(len(resp.json['tasks']), 1)
self.assertEqual(1, len(resp.json['tasks']))
self.assertDictEqual(TASK, resp.json['tasks'][0])
@mock.patch.object(db_api, 'get_task_executions', MOCK_EMPTY)
def test_get_all_empty(self):
resp = self.app.get('/v2/tasks')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(len(resp.json['tasks']), 0)
self.assertEqual(0, len(resp.json['tasks']))
@mock.patch.object(db_api, 'get_workflow_execution', MOCK_WF_EX)
@mock.patch.object(db_api, 'get_task_execution', MOCK_RERUN_TASKS)
@ -177,7 +177,7 @@ class TestTasksController(base.FunctionalTest):
resp = self.app.put_json('/v2/tasks/123', params=params)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual(TASK, resp.json)
@mock.patch.object(db_api, 'get_workflow_execution', MOCK_WF_EX)
@ -191,7 +191,7 @@ class TestTasksController(base.FunctionalTest):
params=params,
expect_errors=True)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn('faultstring', resp.json)
self.assertIn('Mandatory field missing', resp.json['faultstring'])
@ -204,7 +204,7 @@ class TestTasksController(base.FunctionalTest):
resp = self.app.put_json('/v2/tasks/123', params=params)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual(TASK, resp.json)
@mock.patch.object(db_api, 'get_workflow_execution', MOCK_WF_EX)
@ -219,7 +219,7 @@ class TestTasksController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn('faultstring', resp.json)
self.assertIn('execution must be in ERROR', resp.json['faultstring'])
@ -236,7 +236,7 @@ class TestTasksController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn('faultstring', resp.json)
self.assertIn('Invalid task state', resp.json['faultstring'])
@ -252,7 +252,7 @@ class TestTasksController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn('faultstring', resp.json)
self.assertIn('Only with-items task', resp.json['faultstring'])
@ -269,7 +269,7 @@ class TestTasksController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn('faultstring', resp.json)
self.assertIn('Task name does not match', resp.json['faultstring'])
@ -286,6 +286,6 @@ class TestTasksController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn('faultstring', resp.json)
self.assertIn('Workflow name does not match', resp.json['faultstring'])

View File

@ -106,14 +106,14 @@ class TestWorkbooksController(base.FunctionalTest):
def test_get(self):
resp = self.app.get('/v2/workbooks/123')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual(WORKBOOK, resp.json)
@mock.patch.object(db_api, "get_workbook", MOCK_NOT_FOUND)
def test_get_not_found(self):
resp = self.app.get('/v2/workbooks/123', expect_errors=True)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
@mock.patch.object(workbooks, "update_workbook_v2", MOCK_UPDATED_WORKBOOK)
def test_put(self):
@ -123,7 +123,7 @@ class TestWorkbooksController(base.FunctionalTest):
headers={'Content-Type': 'text/plain'}
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(UPDATED_WORKBOOK, resp.json)
@mock.patch.object(workbooks, "update_workbook_v2", MOCK_NOT_FOUND)
@ -135,7 +135,7 @@ class TestWorkbooksController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
def test_put_invalid(self):
resp = self.app.put(
@ -145,7 +145,7 @@ class TestWorkbooksController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Invalid DSL", resp.body)
@mock.patch.object(workbooks, "create_workbook_v2", MOCK_WORKBOOK)
@ -156,7 +156,7 @@ class TestWorkbooksController(base.FunctionalTest):
headers={'Content-Type': 'text/plain'}
)
self.assertEqual(resp.status_int, 201)
self.assertEqual(201, resp.status_int)
self.assertEqual(WORKBOOK, resp.json)
@mock.patch.object(workbooks, "create_workbook_v2", MOCK_DUPLICATE)
@ -168,7 +168,7 @@ class TestWorkbooksController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 409)
self.assertEqual(409, resp.status_int)
def test_post_invalid(self):
resp = self.app.post(
@ -178,37 +178,37 @@ class TestWorkbooksController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Invalid DSL", resp.body)
@mock.patch.object(db_api, "delete_workbook", MOCK_DELETE)
def test_delete(self):
resp = self.app.delete('/v2/workbooks/123')
self.assertEqual(resp.status_int, 204)
self.assertEqual(204, resp.status_int)
@mock.patch.object(db_api, "delete_workbook", MOCK_NOT_FOUND)
def test_delete_not_found(self):
resp = self.app.delete('/v2/workbooks/123', expect_errors=True)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
@mock.patch.object(db_api, "get_workbooks", MOCK_WORKBOOKS)
def test_get_all(self):
resp = self.app.get('/v2/workbooks')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(len(resp.json['workbooks']), 1)
self.assertEqual(1, len(resp.json['workbooks']))
self.assertDictEqual(WORKBOOK, resp.json['workbooks'][0])
@mock.patch.object(db_api, "get_workbooks", MOCK_EMPTY)
def test_get_all_empty(self):
resp = self.app.get('/v2/workbooks')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(len(resp.json['workbooks']), 0)
self.assertEqual(0, len(resp.json['workbooks']))
def test_validate(self):
resp = self.app.post(
@ -217,7 +217,7 @@ class TestWorkbooksController(base.FunctionalTest):
headers={'Content-Type': 'text/plain'}
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertTrue(resp.json['valid'])
def test_validate_invalid_model_exception(self):
@ -228,7 +228,7 @@ class TestWorkbooksController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertFalse(resp.json['valid'])
self.assertIn("Invalid DSL", resp.json['error'])
@ -240,7 +240,7 @@ class TestWorkbooksController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertFalse(resp.json['valid'])
self.assertIn("Definition could not be parsed", resp.json['error'])
@ -252,7 +252,7 @@ class TestWorkbooksController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertFalse(resp.json['valid'])
self.assertIn("unexpected '*' at position 1",
resp.json['error'])
@ -265,6 +265,6 @@ class TestWorkbooksController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertFalse(resp.json['valid'])
self.assertIn("Invalid DSL", resp.json['error'])

View File

@ -155,7 +155,7 @@ class TestWorkflowsController(base.FunctionalTest):
def test_get(self):
resp = self.app.get('/v2/workflows/123')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual(WF, resp.json)
@mock.patch.object(db_api, "get_workflow_definition", MOCK_WF_WITH_INPUT)
@ -164,14 +164,14 @@ class TestWorkflowsController(base.FunctionalTest):
self.maxDiff = None
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual(WF_WITH_DEFAULT_INPUT, resp.json)
@mock.patch.object(db_api, "get_workflow_definition", MOCK_NOT_FOUND)
def test_get_not_found(self):
resp = self.app.get('/v2/workflows/123', expect_errors=True)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
@mock.patch.object(
db_api, "update_workflow_definition", MOCK_UPDATED_WF
@ -185,7 +185,7 @@ class TestWorkflowsController(base.FunctionalTest):
self.maxDiff = None
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual({'workflows': [UPDATED_WF]}, resp.json)
@mock.patch.object(
@ -199,7 +199,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Attempt to modify a system workflow", resp.text)
@mock.patch.object(db_api, "update_workflow_definition")
@ -212,7 +212,7 @@ class TestWorkflowsController(base.FunctionalTest):
headers={'Content-Type': 'text/plain'}
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual({'workflows': [UPDATED_WF]}, resp.json)
self.assertEqual("public", mock_update.call_args[0][1]['scope'])
@ -229,7 +229,7 @@ class TestWorkflowsController(base.FunctionalTest):
self.maxDiff = None
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertDictEqual({'workflows': [WF_WITH_DEFAULT_INPUT]}, resp.json)
@mock.patch.object(
@ -243,7 +243,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True,
)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
def test_put_invalid(self):
resp = self.app.put(
@ -253,7 +253,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Invalid DSL", resp.body)
@mock.patch.object(db_api, "create_workflow_definition")
@ -266,7 +266,7 @@ class TestWorkflowsController(base.FunctionalTest):
headers={'Content-Type': 'text/plain'}
)
self.assertEqual(resp.status_int, 201)
self.assertEqual(201, resp.status_int)
self.assertDictEqual({'workflows': [WF]}, resp.json)
self.assertEqual(1, mock_mtd.call_count)
@ -286,7 +286,7 @@ class TestWorkflowsController(base.FunctionalTest):
headers={'Content-Type': 'text/plain'}
)
self.assertEqual(resp.status_int, 201)
self.assertEqual(201, resp.status_int)
self.assertEqual({"workflows": [WF]}, resp.json)
self.assertEqual("public", mock_mtd.call_args[0][0]['scope'])
@ -302,7 +302,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Scope must be one of the following", resp.text)
@mock.patch.object(db_api, "create_workflow_definition", MOCK_DUPLICATE)
@ -314,7 +314,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 409)
self.assertEqual(409, resp.status_int)
def test_post_invalid(self):
resp = self.app.post(
@ -324,7 +324,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Invalid DSL", resp.body)
@mock.patch.object(db_api, "delete_workflow_definition", MOCK_DELETE)
@ -332,48 +332,48 @@ class TestWorkflowsController(base.FunctionalTest):
def test_delete(self):
resp = self.app.delete('/v2/workflows/123')
self.assertEqual(resp.status_int, 204)
self.assertEqual(204, resp.status_int)
@mock.patch.object(db_api, "get_workflow_definition", MOCK_WF_SYSTEM)
def test_delete_system(self):
resp = self.app.delete('/v2/workflows/123', expect_errors=True)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Attempt to delete a system workflow", resp.text)
@mock.patch.object(db_api, "delete_workflow_definition", MOCK_NOT_FOUND)
def test_delete_not_found(self):
resp = self.app.delete('/v2/workflows/123', expect_errors=True)
self.assertEqual(resp.status_int, 404)
self.assertEqual(404, resp.status_int)
@mock.patch.object(db_api, "get_workflow_definitions", MOCK_WFS)
def test_get_all(self):
resp = self.app.get('/v2/workflows')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(len(resp.json['workflows']), 1)
self.assertEqual(1, len(resp.json['workflows']))
self.assertDictEqual(WF, resp.json['workflows'][0])
@mock.patch.object(db_api, "get_workflow_definitions", MOCK_EMPTY)
def test_get_all_empty(self):
resp = self.app.get('/v2/workflows')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertEqual(len(resp.json['workflows']), 0)
self.assertEqual(0, len(resp.json['workflows']))
@mock.patch.object(db_api, "get_workflow_definitions", MOCK_WFS)
def test_get_all_pagination(self):
resp = self.app.get(
'/v2/workflows?limit=1&sort_keys=id,name')
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertIn('next', resp.json)
self.assertEqual(len(resp.json['workflows']), 1)
self.assertEqual(1, len(resp.json['workflows']))
self.assertDictEqual(WF, resp.json['workflows'][0])
param_dict = utils.get_dict_from_string(
@ -396,7 +396,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Limit must be positive", resp.body)
@ -406,7 +406,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("unable to convert to int", resp.body)
@ -416,7 +416,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn(
"Length of sort_keys must be equal or greater than sort_dirs",
@ -429,7 +429,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn("Unknown sort direction", resp.body)
@ -441,8 +441,8 @@ class TestWorkflowsController(base.FunctionalTest):
resp = self.app.get('/v2/workflows?fields=name')
self.assertEqual(resp.status_int, 200)
self.assertEqual(len(resp.json['workflows']), 1)
self.assertEqual(200, resp.status_int)
self.assertEqual(1, len(resp.json['workflows']))
expected_dict = {
'id': '123e4567-e89b-12d3-a456-426655440000',
@ -457,7 +457,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 400)
self.assertEqual(400, resp.status_int)
self.assertIn(
"nonexist are invalid",
@ -471,7 +471,7 @@ class TestWorkflowsController(base.FunctionalTest):
headers={'Content-Type': 'text/plain'}
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertTrue(resp.json['valid'])
def test_validate_invalid_model_exception(self):
@ -482,7 +482,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertFalse(resp.json['valid'])
self.assertIn("Invalid DSL", resp.json['error'])
@ -494,7 +494,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertFalse(resp.json['valid'])
self.assertIn("Definition could not be parsed", resp.json['error'])
@ -506,7 +506,7 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertFalse(resp.json['valid'])
self.assertIn("unexpected '*' at position 1",
resp.json['error'])
@ -519,6 +519,6 @@ class TestWorkflowsController(base.FunctionalTest):
expect_errors=True
)
self.assertEqual(resp.status_int, 200)
self.assertEqual(200, resp.status_int)
self.assertFalse(resp.json['valid'])
self.assertIn("Invalid DSL", resp.json['error'])

View File

@ -235,4 +235,4 @@ class TriggerServiceV2Test(base.DbTestCase):
trigger_names = [t.name for t in t_s.get_next_cron_triggers()]
self.assertEqual(trigger_names, ['test2', 'test1', 'test3'])
self.assertEqual(['test2', 'test1', 'test3'], trigger_names)

View File

@ -27,23 +27,23 @@ class ExceptionTestCase(base.BaseTest):
exc = exceptions.NotFoundException('check_for_this')
self.assertIn('check_for_this',
six.text_type(exc))
self.assertEqual(exc.http_code, 404)
self.assertEqual(404, exc.http_code)
def test_nf_with_no_message(self):
exc = exceptions.NotFoundException()
self.assertIn("Object not found",
six.text_type(exc))
self.assertEqual(exc.http_code, 404)
self.assertEqual(404, exc.http_code,)
def test_duplicate_obj_code(self):
exc = exceptions.DBDuplicateEntryException()
self.assertIn("Database object already exists",
six.text_type(exc))
self.assertEqual(exc.http_code, 409)
self.assertEqual(409, exc.http_code,)
def test_default_code(self):
exc = exceptions.EngineException()
self.assertEqual(exc.http_code, 500)
self.assertEqual(500, exc.http_code)
def test_default_message(self):
exc = exceptions.EngineException()

View File

@ -43,14 +43,14 @@ class YaqlEvaluatorTest(base.BaseTest):
def test_expression_result(self):
res = self._evaluator.evaluate('$.server', DATA)
self.assertEqual(res, {
self.assertEqual({
'id': "03ea824a-aa24-4105-9131-66c48ae54acf",
'name': 'cloud-fedora',
'status': 'ACTIVE'
})
}, res)
res = self._evaluator.evaluate('$.server.id', DATA)
self.assertEqual(res, '03ea824a-aa24-4105-9131-66c48ae54acf')
self.assertEqual('03ea824a-aa24-4105-9131-66c48ae54acf', res)
res = self._evaluator.evaluate("$.server.status = 'ACTIVE'", DATA)
self.assertTrue(res)
@ -68,7 +68,7 @@ class YaqlEvaluatorTest(base.BaseTest):
expression_str = 'invalid_expression_string'
res = self._evaluator.evaluate(expression_str, DATA)
self.assertEqual(res, expression_str)
self.assertEqual(expression_str, res)
def test_select_result(self):
res = self._evaluator.evaluate(
@ -76,7 +76,7 @@ class YaqlEvaluatorTest(base.BaseTest):
SERVERS
)
item = list(res)[0]
self.assertEqual(item, {'name': 'ubuntu'})
self.assertEqual({'name': 'ubuntu'}, item)
def test_function_string(self):
self.assertEqual('3', self._evaluator.evaluate('str($)', '3'))
@ -216,7 +216,7 @@ class ExpressionsTest(base.BaseTest):
for expression, expected in test_cases:
actual = expr.evaluate_recursively(expression, data)
self.assertEqual(actual, expected)
self.assertEqual(expected, actual)
def test_evaluate_recursively(self):
task_spec_dict = {
@ -308,4 +308,4 @@ class ExpressionsTest(base.BaseTest):
applied = expr.evaluate_recursively(defaults, context)
expected = 'mysql://admin:secrete@vm1234.example.com/test'
self.assertEqual(applied['conn'], expected)
self.assertEqual(expected, applied['conn'])