Merge "Added test cases for a few possible scenarios"

This commit is contained in:
Jenkins 2016-12-21 12:52:52 +00:00 committed by Gerrit Code Review
commit 32a6e3c8da

View File

@ -266,6 +266,20 @@ class TestTasksController(base.APITest):
self.assertIn('faultstring', resp.json)
self.assertIn('execution must be in ERROR', resp.json['faultstring'])
@mock.patch.object(db_api, 'get_workflow_execution', MOCK_WF_EX)
@mock.patch.object(db_api, 'get_task_execution', MOCK_ERROR_TASK)
def test_put_current_task_in_error(self):
params = copy.deepcopy(RERUN_TASK)
params['reset'] = True
params['env'] = '{"k1": "def"}'
resp = self.app.put_json(
'/v2/tasks/123',
params=params,
)
self.assertEqual(200, resp.status_int)
@mock.patch.object(db_api, 'get_workflow_execution', MOCK_WF_EX)
@mock.patch.object(db_api, 'get_task_execution', MOCK_ERROR_TASK)
def test_put_invalid_state(self):
@ -299,6 +313,20 @@ class TestTasksController(base.APITest):
self.assertIn('faultstring', resp.json)
self.assertIn('Only with-items task', resp.json['faultstring'])
@mock.patch.object(db_api, 'get_workflow_execution', MOCK_WF_EX)
@mock.patch.object(db_api, 'get_task_execution', MOCK_ERROR_TASK)
def test_put_valid_state(self):
params = copy.deepcopy(RERUN_TASK)
params['state'] = states.RUNNING
params['reset'] = True
resp = self.app.put_json(
'/v2/tasks/123',
params=params
)
self.assertEqual(200, resp.status_int)
@mock.patch.object(db_api, 'get_workflow_execution', MOCK_WF_EX)
@mock.patch.object(db_api, 'get_task_execution', MOCK_ERROR_TASK)
def test_put_mismatch_task_name(self):
@ -316,6 +344,21 @@ class TestTasksController(base.APITest):
self.assertIn('faultstring', resp.json)
self.assertIn('Task name does not match', resp.json['faultstring'])
@mock.patch.object(db_api, 'get_workflow_execution', MOCK_WF_EX)
@mock.patch.object(db_api, 'get_task_execution', MOCK_ERROR_TASK)
def test_put_match_task_name(self):
params = copy.deepcopy(RERUN_TASK)
params['name'] = 'task'
params['reset'] = True
resp = self.app.put_json(
'/v2/tasks/123',
params=params,
expect_errors=True
)
self.assertEqual(200, resp.status_int)
@mock.patch.object(db_api, 'get_workflow_execution', MOCK_WF_EX)
@mock.patch.object(db_api, 'get_task_execution', MOCK_ERROR_TASK)
def test_put_mismatch_workflow_name(self):