changeset 2d70f0eb6684 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=2d70f0eb6684
description:
Add test for executing wizard without access
issue9108
review261041002
diffstat:
trytond/tests/test_wizard.py | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diffs (38 lines):
diff -r 6ed96b847340 -r 2d70f0eb6684 trytond/tests/test_wizard.py
--- a/trytond/tests/test_wizard.py Mon Mar 09 18:24:23 2020 +0100
+++ b/trytond/tests/test_wizard.py Mon Mar 09 18:24:54 2020 +0100
@@ -1,6 +1,8 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of this
# repository contains the full copyright notices and license terms.
import unittest
+
+from trytond.model.exceptions import AccessError
from trytond.tests.test_tryton import activate_module, with_transaction
from trytond.transaction import Transaction
from trytond.pool import Pool
@@ -106,6 +108,25 @@
}}, 'next_')
self.assertEqual(len(result['actions']), 1)
+ @with_transaction()
+ def test_execute_without_access(self):
+ "Execute wizard without model access"
+ pool = Pool()
+ Wizard = pool.get('test.test_wizard', type='wizard')
+ Model = pool.get('ir.model')
+ ModelAccess = pool.get('ir.model.access')
+ model, = Model.search([('model', '=', 'test.access')])
+ ModelAccess.create([{
+ 'model': model.id,
+ 'perm_write': False,
+ }])
+
+ session_id, start_state, end_state = Wizard.create()
+
+ with self.assertRaises(AccessError):
+ with Transaction().set_context(active_model='test.access'):
+ Wizard.execute(session_id, {}, start_state)
+
def suite():
return unittest.TestLoader().loadTestsFromTestCase(WizardTestCase)