[IMP] report_xlsx: test performance improvement
- Switch to setUpClass for avoiding repeat the same setup for each test. - Include context keys for avoiding mail operations overhead.pull/804/head
parent
e137a99980
commit
554eeae329
|
@ -14,15 +14,26 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
class TestReport(common.TransactionCase):
|
class TestReport(common.TransactionCase):
|
||||||
def setUp(self):
|
@classmethod
|
||||||
super().setUp()
|
def setUpClass(cls):
|
||||||
report_object = self.env["ir.actions.report"]
|
super().setUpClass()
|
||||||
self.xlsx_report = self.env["report.report_xlsx.abstract"].with_context(
|
# 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))
|
||||||
|
report_object = cls.env["ir.actions.report"]
|
||||||
|
cls.xlsx_report = cls.env["report.report_xlsx.abstract"].with_context(
|
||||||
active_model="res.partner"
|
active_model="res.partner"
|
||||||
)
|
)
|
||||||
self.report_name = "report_xlsx.partner_xlsx"
|
cls.report_name = "report_xlsx.partner_xlsx"
|
||||||
self.report = report_object._get_report_from_name(self.report_name)
|
cls.report = report_object._get_report_from_name(cls.report_name)
|
||||||
self.docs = self.env["res.company"].search([], limit=1).partner_id
|
cls.docs = cls.env["res.company"].search([], limit=1).partner_id
|
||||||
|
|
||||||
def test_report(self):
|
def test_report(self):
|
||||||
report = self.report
|
report = self.report
|
||||||
|
|
Loading…
Reference in New Issue