reporting-engine/report_context/tests/test_report_context.py

48 lines
2.2 KiB
Python
Raw Normal View History

2021-03-23 19:37:36 +00:00
# Copyright 2019 Creu Blanca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from flectra.tests.common import TransactionCase
class TestReportContext(TransactionCase):
def test_report_01(self):
company = self.browse_ref('base.main_company')
report = self.browse_ref('web.action_report_internalpreview')
self.env['ir.config_parameter'].sudo().set_param(
'report.default.context', '{"test_parameter": 1}')
report.write({'context': '{"test_parameter": 2}'})
action = report.with_context(test_parameter=3).report_action(company)
self.assertEqual(3, action['context']['test_parameter'])
def test_report_02(self):
company = self.browse_ref('base.main_company')
report = self.browse_ref('web.action_report_internalpreview')
self.env['ir.config_parameter'].sudo().set_param(
'report.default.context', '{"test_parameter": 1}')
report.write({'context': '{"test_parameter": 2}'})
action = report.report_action(company)
self.assertEqual(2, action['context']['test_parameter'])
def test_report_03(self):
company = self.browse_ref('base.main_company')
report = self.browse_ref('web.action_report_internalpreview')
self.env['ir.config_parameter'].sudo().set_param(
'report.default.context', '{"test_parameter": 1}')
action = report.with_context(test_parameter=3).report_action(company)
self.assertEqual(3, action['context']['test_parameter'])
def test_report_04(self):
company = self.browse_ref('base.main_company')
report = self.browse_ref('web.action_report_internalpreview')
report.write({'context': '{"test_parameter": 2}'})
action = report.report_action(company)
self.assertEqual(2, action['context']['test_parameter'])
def test_report_05(self):
company = self.browse_ref('base.main_company')
report = self.browse_ref('web.action_report_internalpreview')
self.env['ir.config_parameter'].sudo().set_param(
'report.default.context', '{"test_parameter": 1}')
action = report.report_action(company)
self.assertEqual(1, action['context']['test_parameter'])