def test_multiple_jobs(self): city_result = evalmgr_job.delay(dict(recipe=hunting, area='city')) forest_result = evalmgr_job.delay(dict(recipe=hunting, area='forest')) jungle_result = evalmgr_job.delay(dict(recipe=hunting, area='jungle')) self.assertEqual('Hedgehog hunted.', forest_result.get()['output']) self.assertEqual('Epic fail.', city_result.get()['output']) self.assertEqual('Epic fail.', jungle_result.get()['output'])
def test_error_behavior(self): case = 1 tests = [ # evaluation error (dict(recipe=hunting, area='elevator', error_handlers=self.error_handlers), HuntingException, 'ARRESTED', 'ashamed'), # job with no recipe (dict(very_important_task='kill another hedgehog remotely', error_handlers=self.arrest), RuntimeError, 'ARRESTED', None), # handler not returning environment (dict(recipe=hunting, area='blackhole', error_handlers=self.arrest), RuntimeError, 'ARRESTED', None), # corrupted error handler (dict(recipe=hunting, area='elevator', error_handlers=self.corrupted_error_handler), HuntingException, None, None)] for env, exception, status, mood in tests: police_files.clear() env['case'] = case with self.assertRaises(exception): evalmgr_job.delay(env).get() if status: self.assertEqual(status, police_files[case]['suspect_status']) if mood: self.assertEqual(mood, police_files[case]['suspect_mood'])
def test_multiple_source_file_evaluation(self): good_env = self.evaluation_env.copy() wrong_env = self.evaluation_env.copy() wrong_env.update(local_source_file=self.local_wrong_source_file, remote_source_file=self.remote_wrong_source_file) good_result = evalmgr_job.delay(good_env) wrong_result = evalmgr_job.delay(wrong_env) self.assertEqual('OK', good_result.get()['result_code']) self.assertEqual('WA', wrong_result.get()['result_code'])
def test_multiple_source_file_evaluation(self): good_env = self.evaluation_env.copy() wrong_env = self.evaluation_env.copy() wrong_env.update( local_source_file=self.local_wrong_source_file, remote_source_file=self.remote_wrong_source_file ) good_result = evalmgr_job.delay(good_env) wrong_result = evalmgr_job.delay(wrong_env) self.assertEqual('OK', good_result.get()['result_code']) self.assertEqual('WA', wrong_result.get()['result_code'])
class TestErrorBehavior(unittest.TestCase): error_handlers = [('Call police', 'oioioi.evalmgr.tests.tests.police_handler'), ('Be ashamed', 'oioioi.evalmgr.tests.tests.set_mood', { 'mood': 'ashamed' })] arrest = [('Call police', 'oioioi.evalmgr.tests.tests.police_handler')] corrupted_error_handler = [ ('Call police', 'oioioi.evalmgr.tests.tests.corrupted_police_handler') ] def test_error_behavior(self): case = 1 tests = [ # evaluation error (dict(recipe=hunting, area='elevator', error_handlers=self.error_handlers), HuntingException, 'ARRESTED', 'ashamed'), # job with no recipe (dict(very_important_task='kill another hedgehog remotely', error_handlers=self.arrest), RuntimeError, 'ARRESTED', None), # handler not returning environment (dict(recipe=hunting, area='blackhole', error_handlers=self.arrest), RuntimeError, 'ARRESTED', None), # corrupted error handler (dict(recipe=hunting, area='elevator', error_handlers=self.corrupted_error_handler), HuntingException, None, None) ] for env, exception, status, mood in tests: police_files.clear() env['case'] = case with self.assertRaises(exception): evalmgr_job.delay(env).get() if status: self.assertEqual(status, police_files[case]['suspect_status']) if mood: self.assertEqual(mood, police_files[case]['suspect_mood'])
def test_cascade_job(self): env = dict(recipe=hunting, area='forest') env = evalmgr_job.delay(env).get() self.assertEqual('Hedgehog hunted.', env['output'])
def test_full_source_file_evaluation(self): env = self.evaluation_env.copy() env = evalmgr_job.delay(env).get() self.assertEqual('OK', env['result_code'])