def test_channel_on_job(self): method = self.env["test.queue.channel"].job_a path_a = self.env["queue.job.function"].job_function_name( "test.queue.channel", "job_a") job_func = self.function_model.search([("name", "=", path_a)]) self.assertEqual(job_func.channel, "root") test_job = Job(method) test_job.store() stored = test_job.db_record() self.assertEqual(stored.channel, "root") job_read = Job.load(self.env, test_job.uuid) self.assertEqual(job_read.channel, "root") sub_channel = self.env.ref("test_queue_job.channel_sub") job_func.channel_id = sub_channel test_job = Job(method) test_job.store() stored = test_job.db_record() self.assertEqual(stored.channel, "root.sub") # it's also possible to override the channel test_job = Job(method, channel="root.sub") test_job.store() stored = test_job.db_record() self.assertEqual(stored.channel, test_job.channel)
def test_old_jobs_are_deleted(self): """ Old jobs are deleted by the autovacuum cron job. """ test_job = Job(self.method) test_job.set_done(result='ok') test_job.date_done = datetime.datetime.now() - datetime.timedelta( days=self.queue_job._removal_interval + 1) test_job.store() self.cron_job.method_direct_trigger() self.assertFalse(test_job.db_record().exists())
def test_kwargs(self): """ Job with related action check if action propagates kwargs """ job_ = Job(self.model.testing_related_action__kwargs) self.assertEqual(job_.related_action(), (job_.db_record(), {'b': 4}))
def test_return(self): """ Job with related action check if action returns correctly """ job = Job(self.method) act_job, act_kwargs = job.related_action() self.assertEqual(act_job, job.db_record()) self.assertEqual(act_kwargs, {})
def test_default_channel_no_xml(self): """Channel on job is root if there is no queue.job.function record""" test_job = Job(self.env["res.users"].browse) test_job.store() stored = test_job.db_record() self.assertEqual(stored.channel, "root")