本文整理汇总了Python中openerp.addons.connector.queue.job.OpenERPJobStorage类的典型用法代码示例。如果您正苦于以下问题:Python OpenERPJobStorage类的具体用法?Python OpenERPJobStorage怎么用?Python OpenERPJobStorage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OpenERPJobStorage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_job
def _create_job(self):
test_job = Job(func=task_a)
storage = OpenERPJobStorage(self.session)
storage.store(test_job)
stored = storage.db_record_from_uuid(test_job.uuid)
self.assertEqual(len(stored), 1)
return stored
示例2: _create_job
def _create_job(self, func, *args):
job = Job(func=func, args=args)
storage = OpenERPJobStorage(self.session)
storage.store(job)
stored = self.QueueJob.search([("uuid", "=", job.uuid)])
self.assertEqual(len(stored), 1)
return stored
示例3: _cancel_jobs
def _cancel_jobs(self, cr, uid, context=None):
"""Find moves where the mark has been removed and cancel the jobs.
For the moves that are posted already it's too late: we skip them.
"""
if context is None:
context = {}
session = ConnectorSession(cr, uid, context=context)
storage = OpenERPJobStorage(session)
move_ids = self.search(cr, uid, [
('to_post', '=', False),
('post_job_uuid', '!=', False),
('state', '=', 'draft'),
], context=context)
for move in self.browse(cr, uid, move_ids, context=context):
job = storage.load(move.post_job_uuid)
if job.state in (u'pending', u'enqueued'):
job.set_done(result=_(
u'Task set to Done because the user unmarked the move'
))
storage.store(job)
示例4: _create_job
def _create_job(self):
test_job = Job(func=task_a)
storage = OpenERPJobStorage(self.session)
storage.store(test_job)
stored = self.queue_job.search([("uuid", "=", test_job.uuid)])
self.assertEqual(len(stored), 1)
return stored
示例5: test_job_unlinked
def test_job_unlinked(self):
test_job = Job(func=dummy_task_args, model_name="res.users", args=("o", "k"), kwargs={"c": "!"})
storage = OpenERPJobStorage(self.session)
storage.store(test_job)
stored = self.queue_job.search([("uuid", "=", test_job.uuid)])
stored.unlink()
with self.assertRaises(NoSuchJobError):
storage.load(test_job.uuid)
示例6: test_store
def test_store(self):
job = Job(func=task_a)
storage = OpenERPJobStorage(self.session)
storage.store(job)
stored = self.queue_job.search(
self.cr, self.uid,
[('uuid', '=', job.uuid)])
self.assertEqual(len(stored), 1)
示例7: test_job_worker
def test_job_worker(self):
worker = self.env["queue.worker"].create({"uuid": "57569b99-c2c1-47b6-aad1-72f953c92c87"})
test_job = Job(func=dummy_task_args, model_name="res.users", args=("o", "k"), kwargs={"c": "!"})
test_job.worker_uuid = worker.uuid
storage = OpenERPJobStorage(self.session)
self.assertEqual(storage._worker_id(worker.uuid), worker.id)
storage.store(test_job)
job_read = storage.load(test_job.uuid)
self.assertEqual(job_read.worker_uuid, worker.uuid)
示例8: _create_job
def _create_job(self, func, *args):
cr, uid = self.cr, self.uid
job = Job(func=func, args=args)
storage = OpenERPJobStorage(self.session)
storage.store(job)
stored_ids = self.QueueJob.search(self.cr, self.uid,
[('uuid', '=', job.uuid)])
self.assertEqual(len(stored_ids), 1)
return self.QueueJob.browse(cr, uid, stored_ids[0])
示例9: test_job_unlinked
def test_job_unlinked(self):
test_job = Job(func=dummy_task_args,
model_name='res.users',
args=('o', 'k'),
kwargs={'c': '!'})
storage = OpenERPJobStorage(self.session)
storage.store(test_job)
stored = self.queue_job.search([('uuid', '=', test_job.uuid)])
stored.unlink()
with self.assertRaises(NoSuchJobError):
storage.load(test_job.uuid)
示例10: test_job_worker
def test_job_worker(self):
worker = self.env['queue.worker'].create(
{'uuid': '57569b99-c2c1-47b6-aad1-72f953c92c87'}
)
test_job = Job(func=dummy_task_args,
model_name='res.users',
args=('o', 'k'),
kwargs={'c': '!'})
test_job.worker_uuid = worker.uuid
storage = OpenERPJobStorage(self.session)
self.assertEqual(storage._worker_id(worker.uuid), worker.id)
storage.store(test_job)
job_read = storage.load(test_job.uuid)
self.assertEqual(job_read.worker_uuid, worker.uuid)
示例11: test_unicode
def test_unicode(self):
test_job = Job(func=dummy_task_args,
model_name='res.users',
args=(u'öô¿‽', u'ñě'),
kwargs={'c': u'ßø'},
priority=15,
description=u"My dé^Wdescription")
test_job.user_id = 1
storage = OpenERPJobStorage(self.session)
storage.store(test_job)
job_read = storage.load(test_job.uuid)
self.assertEqual(test_job.args, job_read.args)
self.assertEqual(job_read.args, ('res.users', u'öô¿‽', u'ñě'))
self.assertEqual(test_job.kwargs, job_read.kwargs)
self.assertEqual(job_read.kwargs, {'c': u'ßø'})
self.assertEqual(test_job.description, job_read.description)
self.assertEqual(job_read.description, u"My dé^Wdescription")
示例12: test_accented_bytestring
def test_accented_bytestring(self):
job = Job(func=dummy_task_args,
model_name='res.users',
args=('öô¿‽', 'ñě'),
kwargs={'c': 'ßø'},
priority=15,
description="My dé^Wdescription")
job.user_id = 1
storage = OpenERPJobStorage(self.session)
storage.store(job)
job_read = storage.load(job.uuid)
self.assertEqual(job.args, job_read.args)
self.assertEqual(job_read.args, ('res.users', 'öô¿‽', 'ñě'))
self.assertEqual(job.kwargs, job_read.kwargs)
self.assertEqual(job_read.kwargs, {'c': 'ßø'})
# the job's description has been created as bytestring but is
# decoded to utf8 by the ORM so make them comparable
self.assertEqual(job.description, job_read.description.encode('utf8'))
self.assertEqual(job_read.description, "My dé^Wdescription".decode('utf8'))
示例13: test_unicode
def test_unicode(self):
test_job = Job(
func=dummy_task_args,
model_name="res.users",
args=(u"öô¿‽", u"ñě"),
kwargs={"c": u"ßø"},
priority=15,
description=u"My dé^Wdescription",
)
test_job.user_id = 1
storage = OpenERPJobStorage(self.session)
storage.store(test_job)
job_read = storage.load(test_job.uuid)
self.assertEqual(test_job.args, job_read.args)
self.assertEqual(job_read.args, ("res.users", u"öô¿‽", u"ñě"))
self.assertEqual(test_job.kwargs, job_read.kwargs)
self.assertEqual(job_read.kwargs, {"c": u"ßø"})
self.assertEqual(test_job.description, job_read.description)
self.assertEqual(job_read.description, u"My dé^Wdescription")
示例14: test_accented_bytestring
def test_accented_bytestring(self):
test_job = Job(
func=dummy_task_args,
model_name="res.users",
args=("öô¿‽", "ñě"),
kwargs={"c": "ßø"},
priority=15,
description="My dé^Wdescription",
)
test_job.user_id = 1
storage = OpenERPJobStorage(self.session)
storage.store(test_job)
job_read = storage.load(test_job.uuid)
self.assertEqual(test_job.args, job_read.args)
self.assertEqual(job_read.args, ("res.users", "öô¿‽", "ñě"))
self.assertEqual(test_job.kwargs, job_read.kwargs)
self.assertEqual(job_read.kwargs, {"c": "ßø"})
# the job's description has been created as bytestring but is
# decoded to utf8 by the ORM so make them comparable
self.assertEqual(test_job.description, job_read.description.encode("utf8"))
self.assertEqual(job_read.description, "My dé^Wdescription".decode("utf8"))
示例15: test_read
def test_read(self):
eta = datetime.now() + timedelta(hours=5)
test_job = Job(func=dummy_task_args,
model_name='res.users',
args=('o', 'k'),
kwargs={'c': '!'},
priority=15,
eta=eta,
description="My description")
test_job.user_id = 1
test_job.company_id = self.env.ref("base.main_company").id
storage = OpenERPJobStorage(self.session)
storage.store(test_job)
job_read = storage.load(test_job.uuid)
self.assertEqual(test_job.uuid, job_read.uuid)
self.assertEqual(test_job.model_name, job_read.model_name)
self.assertEqual(test_job.func, job_read.func)
self.assertEqual(test_job.args, job_read.args)
self.assertEqual(test_job.kwargs, job_read.kwargs)
self.assertEqual(test_job.func_name, job_read.func_name)
self.assertEqual(test_job.func_string, job_read.func_string)
self.assertEqual(test_job.description, job_read.description)
self.assertEqual(test_job.state, job_read.state)
self.assertEqual(test_job.priority, job_read.priority)
self.assertEqual(test_job.exc_info, job_read.exc_info)
self.assertEqual(test_job.result, job_read.result)
self.assertEqual(test_job.user_id, job_read.user_id)
self.assertEqual(test_job.company_id, job_read.company_id)
delta = timedelta(seconds=1) # DB does not keep milliseconds
self.assertAlmostEqual(test_job.date_created, job_read.date_created,
delta=delta)
self.assertAlmostEqual(test_job.date_started, job_read.date_started,
delta=delta)
self.assertAlmostEqual(test_job.date_enqueued, job_read.date_enqueued,
delta=delta)
self.assertAlmostEqual(test_job.date_done, job_read.date_done,
delta=delta)
self.assertAlmostEqual(test_job.eta, job_read.eta,
delta=delta)
test_date = datetime(2015, 3, 15, 21, 7, 0)
job_read.date_enqueued = test_date
job_read.date_started = test_date
job_read.date_done = test_date
job_read.canceled = True
storage.store(job_read)
job_read = storage.load(test_job.uuid)
self.assertAlmostEqual(job_read.date_started, test_date,
delta=delta)
self.assertAlmostEqual(job_read.date_enqueued, test_date,
delta=delta)
self.assertAlmostEqual(job_read.date_done, test_date,
delta=delta)
self.assertEqual(job_read.canceled, True)