def test_create_and_cancel(self): # Create 3 meaningless jobs. We're just testing job setup and # cancellation here, not the execution. utils.async_get_result_rows(None, None, {}) job_options = { 'name': 'Job X', } job_x_id = utils.async_get_result_rows(None, None, {}, job_options) job_options = { 'name': 'Job Y', 'query_name': 'job_y_query', } job_y_id = utils.async_get_result_rows(None, None, {}, job_options) self.assertEqual(async_utils.get_job_count(), 3) jobs = async_utils.get_jobs() self.assertEqual(len(jobs), 3) job_x = async_utils.get_job(job_x_id) self.assertTrue(job_x in jobs) self.assertEqual(job_x.meta['name'], 'Job X') self.assertEqual(async_utils.cancel_job(job_x_id), None) self.assertEqual(async_utils.get_job_count(), 2) async_utils.cancel_job('invalid_id') self.assertEqual(async_utils.get_job_count(), 2) self.assertTrue('canceled' in async_utils.cancel_job(job_y_id)) self.assertTrue(async_utils.get_job_count(), 1) async_utils.cancel_all_jobs() self.assertEqual(async_utils.get_job_count(), 0)
def test_create_and_cancel(self): # Create 3 meaningless jobs. We're just testing job setup and # cancellation here, not the execution. job_options = { 'name': 'Job X', } job_x_id = utils.async_get_result_rows(None, None, {}, job_options) job_options = { 'name': 'Job Y', 'query_name': 'job_y_query', } job_y_id = utils.async_get_result_rows(None, None, {}, job_options) job_z_id = utils.async_get_result_rows(None, None, {}) self.assertEqual(async_utils.get_job_count(), 3) jobs = async_utils.get_jobs() self.assertEqual(len(jobs), 3) job_x = async_utils.get_job(job_x_id) self.assertTrue(job_x in jobs) self.assertEqual(job_x.meta['name'], 'Job X') job_y = async_utils.get_job(job_y_id) job_z = async_utils.get_job(job_z_id) self.assertEqual(async_utils.cancel_job(job_x_id), None) # Prove job is gone from Redis with self.assertRaises(NoSuchJobError): job_x.refresh() # Prove job is gone from queue self.assertEqual(async_utils.get_job_count(), 2) async_utils.cancel_job('invalid_id') self.assertEqual(async_utils.get_job_count(), 2) self.assertTrue('canceled' in async_utils.cancel_job(job_y_id)) self.assertTrue(async_utils.get_job_count(), 1) async_utils.cancel_all_jobs() with self.assertRaises(NoSuchJobError): job_y.refresh() with self.assertRaises(NoSuchJobError): job_z.refresh() self.assertEqual(async_utils.get_job_count(), 0)
def setUp(self): super(AsyncExporterResourceTestCase, self).setUp() utils.cancel_all_jobs()
def setUp(self): # Clear all jobs before each test case just in case any lingering jobs # remain. utils.cancel_all_jobs()
def setUp(self): # Clear all jobs before each test case just in case any lingering jobs # remain. utils.cancel_all_jobs() super(AsyncPreviewResourceProcessorTestCase, self).setUp()
def tearDown(self): # Don't leave any jobs in the queue. async_utils.cancel_all_jobs()
def setUp(self): management.call_command('avocado', 'init', 'tests', quiet=True) # Don't start with any jobs in the queue. async_utils.cancel_all_jobs()
def setUp(self): super(AsyncQueryResultsResourceTestCase, self).setUp() utils.cancel_all_jobs() self.query = DataQuery(user=self.user) self.query.save()
def setUp(self): # Clear all scheduled jobs before each test just in case any # lingering jobs remain. utils.cancel_all_jobs()