|
| 1 | +# Copyright 2018 Onestein |
| 2 | +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
| 3 | + |
| 4 | +from mock import patch |
| 5 | +from odoo.api import Environment |
| 6 | +from odoo.tests.common import SavepointCase |
| 7 | + |
| 8 | + |
| 9 | +class TestDisableExportGroup(SavepointCase): |
| 10 | + @patch('odoo.addons.web_disable_export_group.models.ir_http.request') |
| 11 | + @patch('odoo.addons.web.models.ir_http.request') |
| 12 | + @patch('odoo.addons.web_tour.models.ir_http.request') |
| 13 | + def test_session_info(self, request, request1, request2): |
| 14 | + request.env = self.env |
| 15 | + request1.env = self.env |
| 16 | + request2.env = self.env |
| 17 | + session_info = self.env['ir.http'].session_info() |
| 18 | + self.assertTrue(session_info['group_export_data']) |
| 19 | + |
| 20 | + @patch('odoo.addons.web_disable_export_group.models.ir_http.request') |
| 21 | + @patch('odoo.addons.web.models.ir_http.request') |
| 22 | + @patch('odoo.addons.web_tour.models.ir_http.request') |
| 23 | + def test_session_info_not_allowed(self, request, request1, request2): |
| 24 | + demo_env = Environment( |
| 25 | + self.env.cr, |
| 26 | + self.env.ref('base.default_user').id, |
| 27 | + {} |
| 28 | + ) |
| 29 | + request.env = demo_env |
| 30 | + request1.env = demo_env |
| 31 | + request2.env = demo_env |
| 32 | + session_info = demo_env['ir.http'].session_info() |
| 33 | + self.assertFalse(session_info['group_export_data']) |
0 commit comments