Validate wizard definition on module tests

issue6067
review32831002
This commit is contained in:
Sergi Almacellas Abellana committed 2016-12-21 10:07:57 +01:00
1 parent 361ad96471
commit 04a027a105
3 files changed
+27 -1

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Validate wizard definition on module tests
* Remove order constraint on register ModelSQL
* Add relate from report to translations
+4 -1
View File
@@ -240,7 +240,10 @@ class ShowView(Wizard):
def get_view(self, wizard, state_name):
pool = Pool()
View = pool.get('ir.ui.view')
view = View(Transaction().context.get('active_id'))
view_id = Transaction().context.get('active_id')
if not view_id:
return {}
view = View(view_id)
Model = pool.get(view.model)
return Model.fields_view_get(view_id=view.id)
+22
View File
@@ -22,6 +22,7 @@ from trytond.tools import is_instance_method
from trytond.transaction import Transaction
from trytond.cache import Cache
from trytond.config import config, parse_uri
from trytond.wizard import StateView, StateAction
__all__ = ['POOL', 'DB_NAME', 'USER', 'CONTEXT',
'activate_module', 'ModuleTestCase', 'with_transaction',
@@ -383,6 +384,27 @@ class ModuleTestCase(unittest.TestCase):
'model': model.__name__,
})
@with_transaction()
def test_wizards(self):
'Test wizards are correctly defined'
for wizard_name, wizard in Pool().iterobject(type='wizard'):
if not isregisteredby(wizard, self.module, type_='wizard'):
continue
session_id, start_state, _ = wizard.create()
assert start_state in wizard.states, ('Unknown start state '
'"%(state)s" on wizard "%(wizard)s"' % {
'state': start_state,
'wizard': wizard_name,
})
wizard_instance = wizard(session_id)
for state_name, state in wizard_instance.states.iteritems():
if isinstance(state, StateView):
# Don't test defaults as they may depend on context
state.get_view(wizard_instance, state_name)
state.get_buttons(wizard_instance, state_name)
if isinstance(state, StateAction):
state.get_action()
def db_exist(name=DB_NAME):
Database = backend.get('Database')