Add test for function field methods

It tests if getter, setter and searcher really exists on the model.

issue6616
review34241002
This commit is contained in:
Cédric Krier
2017-07-12 19:58:13 +02:00
parent 4130a14d48
commit fce24f3e4e
2 changed files with 22 additions and 1 deletions
+1
View File
@@ -1,3 +1,4 @@
* Add test for function field methods
* Add option install module dependencies with trytond-admin
* Add localhost_name and timeout as get_smtp_server uri parameters
* Delete missing modules not activated when updating module list
+21 -1
View File
@@ -17,7 +17,7 @@ from sql import Table
from trytond.pool import Pool, isregisteredby
from trytond import backend
from trytond.model import Workflow
from trytond.model.fields import get_eval_fields
from trytond.model.fields import get_eval_fields, Function
from trytond.tools import is_instance_method
from trytond.transaction import Transaction
from trytond.cache import Cache
@@ -435,6 +435,26 @@ class ModuleTestCase(unittest.TestCase):
'model': model.__name__,
})
@with_transaction()
def test_function_fields(self):
"Test function fields methods"
for mname, model in Pool().iterobject():
if not isregisteredby(model, self.module):
continue
for field_name, field in model._fields.iteritems():
if not isinstance(field, Function):
continue
for func_name in [field.getter, field.setter, field.searcher]:
if not func_name:
continue
assert getattr(model, func_name, None), (
"Missing method '%(func_name)s' "
"on model '%(model)s' for field '%(field)s" % {
'func_name': func_name,
'model': model.__name__,
'field': field_name,
})
@with_transaction()
def test_ir_action_window(self):
'Test action windows are correctly defined'