def test_expand_action_defaults(self): job_doc = { 'action_defaults': { 'that_field': 'that_value' }, 'job_actions': [{ 'freezer_action': { 'not_that_field': 'some_value' } }, { 'freezer_action': { 'that_field': 'another_value' } }] } expected_job_doc = { 'job_actions': [{ 'freezer_action': { 'not_that_field': 'some_value', 'that_field': 'that_value' } }, { 'freezer_action': { 'that_field': 'another_value' } }], 'job_schedule': {} } job = v2_jobs.Job(job_doc) self.assertEqual(expected_job_doc, job.doc)
def _test_job_abort(self, status, event, response, need_update): job_schedule = {} if status is not None: job_schedule['status'] = status if event is not None: job_schedule['event'] = event job = v2_jobs.Job({'job_schedule': job_schedule}) res = job.abort() self.assertEqual(response, res) self.assertEqual(need_update, job.need_update)
def test_execute_raises_BadDataFormat_when_event_not_implemented(self): job = v2_jobs.Job({}) self.assertRaises(exceptions.BadDataFormat, job.execute_event, 'smile', 'my_params')
def test_execute_abort_event(self, mock_abort): job = v2_jobs.Job({}) job.execute_event('abort', 'my_params') mock_abort.assert_called_once_with('my_params')
def test_execute_stop_event(self, mock_stop): job = v2_jobs.Job({}) job.execute_event('stop', 'my_params') mock_stop.assert_called_once_with('my_params')