def test_run_one(self): job = JobFactory.create() call_command('run_jobs', job.id, stdout=self.stdout) self.stdout.seek(0) self.assertIn('Started', self.stdout.read())
def test_filter_tags(self, mock_stop, mock_run_job, mock_sleep): JobFactory.create(tag='foo', is_active=True) JobFactory.create(tag='bar', is_active=True) JobFactory.create(tag='ham', is_active=True) call_command('crond', '--tags', 'foo', 'bar', stdout=self.stdout) self.assertEqual(mock_run_job.call_count, 2)
def test_run_with_error(self, mock): job = JobFactory.create() with self.assertRaises(Exception): self.command.run_job(job)
def test_run(self, mock): job = JobFactory.create() result = self.command.run_job(job) self.assertIsNotNone(result) self.assertIsInstance(result, datetime)
def test_not_now(self, mock): job = JobFactory.create() result = self.command.run_job(job) self.assertIsNone(result)
def test_run_two(self): job1, job2 = JobFactory.create_batch(2) call_command('run_jobs', job1.id, job2.id, stdout=self.stdout) self.stdout.seek(0) self.assertIn('Started', self.stdout.read())