mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[IMP] report_async: black, isort, prettier
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tests import common
|
||||
from odoo.tests.common import Form
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class TestJobChannel(common.TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestJobChannel, self).setUp()
|
||||
self.print_doc = self.env.ref('report_async.'
|
||||
'report_async_print_document')
|
||||
self.test_rec = self.env.ref('base.module_mail')
|
||||
self.test_rpt = self.env.ref('base.ir_module_reference_print')
|
||||
self.print_doc = self.env.ref("report_async." "report_async_print_document")
|
||||
self.test_rec = self.env.ref("base.module_mail")
|
||||
self.test_rpt = self.env.ref("base.ir_module_reference_print")
|
||||
|
||||
def _print_wizard(self, res):
|
||||
obj = self.env[res['res_model']]
|
||||
ctx = {'active_model': self.print_doc._name,
|
||||
'active_id': self.print_doc.id, }
|
||||
ctx.update(res['context'])
|
||||
obj = self.env[res["res_model"]]
|
||||
ctx = {
|
||||
"active_model": self.print_doc._name,
|
||||
"active_id": self.print_doc.id,
|
||||
}
|
||||
ctx.update(res["context"])
|
||||
with Form(obj.with_context(ctx)) as form:
|
||||
form.reference = '%s,%s' % (self.test_rec._name, self.test_rec.id)
|
||||
form.reference = "{},{}".format(self.test_rec._name, self.test_rec.id)
|
||||
form.action_report_id = self.test_rpt
|
||||
print_wizard = form.save()
|
||||
return print_wizard
|
||||
@@ -29,19 +29,18 @@ class TestJobChannel(common.TransactionCase):
|
||||
"""Run now will return report action as normal"""
|
||||
res = self.print_doc.run_now()
|
||||
report_action = self._print_wizard(res).print_report()
|
||||
self.assertEquals(report_action['type'], 'ir.actions.report')
|
||||
self.assertEquals(report_action["type"], "ir.actions.report")
|
||||
|
||||
def test_2_run_async(self):
|
||||
"""Run background will return nothing, job started"""
|
||||
with self.assertRaises(UserError):
|
||||
self.print_doc.run_async()
|
||||
self.print_doc.write({'allow_async': True,
|
||||
'email_notify': True})
|
||||
self.print_doc.write({"allow_async": True, "email_notify": True})
|
||||
res = self.print_doc.run_async()
|
||||
print_wizard = self._print_wizard(res)
|
||||
report_action = print_wizard.print_report()
|
||||
self.assertEquals(report_action, {}) # Do not run report yet
|
||||
self.assertEquals(self.print_doc.job_status, 'pending') # Job started
|
||||
self.assertEquals(self.print_doc.job_status, "pending") # Job started
|
||||
# Test produce file (as queue will not run in test mode)
|
||||
docids = [print_wizard.reference.id]
|
||||
data = None
|
||||
|
||||
Reference in New Issue
Block a user