def test_deschedule_by_name(self):
     """We must be able to deschedule a job by giving its name.
     """
     job = schedule('async.tests.test_deschedule._example')
     self.assertEqual(job.name, 'async.tests.test_deschedule._example')
     deschedule('async.tests.test_deschedule._example')
     job = Job.objects.get(pk=job.pk)
     self.assertIsNotNone(job.cancelled)
Beispiel #2
0
 def test_flush_queue_with_cancelled_jobs__should_not_be_executed(self):
     """Make sure that the number of job run by default is 300.
     """
     for _ in xrange(5):
         job = schedule(_dummy)
         deschedule(job.name)
     management.call_command('flush_queue')
     self.assertEqual(Job.objects.filter(executed=None).count(), 5)
     self.assertEqual(Job.objects.filter(cancelled=None).count(), 0)
Beispiel #3
0
 def test_flush_queue_with_cancelled_jobs__should_not_be_executed(self):
     """Make sure that the number of job run by default is 300.
     """
     for _ in xrange(5):
         job = schedule(_dummy)
         deschedule(job.name)
     management.call_command('flush_queue')
     self.assertEqual(Job.objects.filter(executed=None).count(), 5)
     self.assertEqual(Job.objects.filter(cancelled=None).count(), 0)
 def test_deschedule_by_function(self):
     """We must be able to schedule a job by giving a function.
     """
     job = schedule(_example)
     # Different versions of Django will import this file differently
     self.assertTrue(job.name.endswith(
         'async.tests.test_deschedule._example'))
     deschedule(_example)
     job = Job.objects.get(pk=job.pk)
     self.assertIsNotNone(job.cancelled)