diff --git a/web_disable_export_group/tests/__init__.py b/web_disable_export_group/tests/__init__.py new file mode 100644 index 00000000..dc30298a --- /dev/null +++ b/web_disable_export_group/tests/__init__.py @@ -0,0 +1 @@ +from . import test_disable_export_group diff --git a/web_disable_export_group/tests/test_disable_export_group.py b/web_disable_export_group/tests/test_disable_export_group.py new file mode 100644 index 00000000..3315b63e --- /dev/null +++ b/web_disable_export_group/tests/test_disable_export_group.py @@ -0,0 +1,33 @@ +# Copyright 2018 Onestein +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from mock import patch +from odoo.api import Environment +from odoo.tests.common import SavepointCase + + +class TestDisableExportGroup(SavepointCase): + @patch('odoo.addons.web_disable_export_group.models.ir_http.request') + @patch('odoo.addons.web.models.ir_http.request') + @patch('odoo.addons.web_tour.models.ir_http.request') + def test_session_info(self, request, request1, request2): + request.env = self.env + request1.env = self.env + request2.env = self.env + session_info = self.env['ir.http'].session_info() + self.assertTrue(session_info['group_export_data']) + + @patch('odoo.addons.web_disable_export_group.models.ir_http.request') + @patch('odoo.addons.web.models.ir_http.request') + @patch('odoo.addons.web_tour.models.ir_http.request') + def test_session_info_not_allowed(self, request, request1, request2): + demo_env = Environment( + self.env.cr, + self.env.ref('base.default_user').id, + {} + ) + request.env = demo_env + request1.env = demo_env + request2.env = demo_env + session_info = demo_env['ir.http'].session_info() + self.assertFalse(session_info['group_export_data'])