[FIX] view validation tests
bzr revid: chs@openerp.com-20130625170118-dab54jupbexmqoq5
This commit is contained in:
parent
f4332b9b60
commit
f169169377
|
@ -4,7 +4,10 @@ from lxml import etree
|
|||
from StringIO import StringIO
|
||||
import unittest2
|
||||
|
||||
from openerp.tools.view_validation import *
|
||||
from openerp.tools.view_validation import (valid_page_in_book, valid_att_in_form, valid_type_in_colspan,
|
||||
valid_type_in_col, valid_att_in_field, valid_att_in_label,
|
||||
valid_field_in_graph, valid_field_in_tree
|
||||
)
|
||||
|
||||
invalid_form = etree.parse(StringIO('''\
|
||||
<form>
|
||||
|
@ -79,7 +82,7 @@ invalid_tree = etree.parse(StringIO('''\
|
|||
</tree>
|
||||
''')).getroot()
|
||||
|
||||
valid_tree= etree.parse(StringIO('''\
|
||||
valid_tree = etree.parse(StringIO('''\
|
||||
<tree string="">
|
||||
<field name=""></field>
|
||||
<field name=""></field>
|
||||
|
@ -97,12 +100,12 @@ class test_view_validation(unittest2.TestCase):
|
|||
assert valid_page_in_book(valid_form)
|
||||
|
||||
def test_all_field_validation(self):
|
||||
assert not valid_att_in_field(invalid_form)
|
||||
assert valid_att_in_field(valid_form)
|
||||
assert not valid_att_in_field(invalid_form)
|
||||
assert valid_att_in_field(valid_form)
|
||||
|
||||
def test_all_label_validation(self):
|
||||
assert not valid_att_in_label(invalid_form)
|
||||
assert valid_att_in_label(valid_form)
|
||||
assert not valid_att_in_label(invalid_form)
|
||||
assert valid_att_in_label(valid_form)
|
||||
|
||||
def test_form_string_validation(self):
|
||||
assert not valid_att_in_form(invalid_form)
|
||||
|
|
|
@ -40,6 +40,10 @@ def valid_att_in_label(arch):
|
|||
return not arch.xpath('//label[not ((@for) or (@string))]')
|
||||
|
||||
|
||||
def valid_att_in_form(arch):
|
||||
return True
|
||||
|
||||
|
||||
def valid_type_in_colspan(arch):
|
||||
"""A `colspan` attribute must be an `integer` type."""
|
||||
for attrib in arch.xpath('//*/@colspan'):
|
||||
|
@ -62,7 +66,8 @@ def valid_type_in_col(arch):
|
|||
|
||||
def valid_view(arch):
|
||||
if arch.tag == 'form':
|
||||
for pred in [valid_page_in_book, valid_type_in_colspan, valid_type_in_col, valid_att_in_field, valid_att_in_label]:
|
||||
for pred in [valid_page_in_book, valid_att_in_form, valid_type_in_colspan,
|
||||
valid_type_in_col, valid_att_in_field, valid_att_in_label]:
|
||||
if not pred(arch):
|
||||
_logger.error('Invalid XML: %s', pred.__doc__)
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue