mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[IMP] report_xlsx_helper: test performance improvement
- Switch to setUpClass for avoiding repeat the same setup for each test. - Include context keys for avoiding mail operations overhead.
This commit is contained in:
@@ -7,20 +7,31 @@ from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestReportXlsxHelper(TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestReportXlsxHelper, self).setUp()
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestReportXlsxHelper, cls).setUpClass()
|
||||
# Remove this variable in v16 and put instead:
|
||||
# from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
|
||||
DISABLED_MAIL_CONTEXT = {
|
||||
"tracking_disable": True,
|
||||
"mail_create_nolog": True,
|
||||
"mail_create_nosubscribe": True,
|
||||
"mail_notrack": True,
|
||||
"no_reset_password": True,
|
||||
}
|
||||
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
|
||||
today = date.today()
|
||||
p1 = self.env.ref("base.res_partner_1")
|
||||
p2 = self.env.ref("base.res_partner_2")
|
||||
p1 = cls.env.ref("base.res_partner_1")
|
||||
p2 = cls.env.ref("base.res_partner_2")
|
||||
p1.date = today
|
||||
p2.date = today
|
||||
self.partners = p1 + p2
|
||||
cls.partners = p1 + p2
|
||||
ctx = {
|
||||
"report_name": "report_xlsx_helper.test_partner_xlsx",
|
||||
"active_model": "res.partner",
|
||||
"active_ids": self.partners.ids,
|
||||
"active_ids": cls.partners.ids,
|
||||
}
|
||||
self.report = self.env["ir.actions.report"].with_context(**ctx)
|
||||
cls.report = cls.env["ir.actions.report"].with_context(**ctx)
|
||||
|
||||
def test_report_xlsx_helper(self):
|
||||
report_xls = self.report._render_xlsx(None, None)
|
||||
|
||||
Reference in New Issue
Block a user