Validate xml files definition on tests
Update tryton.rnc format and use grouped attribute on message.xml issue8556 review272001002
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data group="1">
|
||||
<data grouped="1">
|
||||
<record model="ir.calendar.month" id="January">
|
||||
<field name="index" eval="1"/>
|
||||
<field name="name">January</field>
|
||||
|
||||
@@ -29,7 +29,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
</record>
|
||||
<menuitem name="Messages" parent="menu_localization" action="act_message_form" id="menu_message_form" sequence="10"/>
|
||||
</data>
|
||||
<data group="1">
|
||||
<data grouped="1">
|
||||
<record model="ir.message" id="msg_id_positive">
|
||||
<field name="text">ID must be positive.</field>
|
||||
</record>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data group="1">
|
||||
<data grouped="1">
|
||||
<record model="ir.message" id="msg_password_length">
|
||||
<field name="text">The password is too short.</field>
|
||||
</record>
|
||||
|
||||
@@ -9,6 +9,7 @@ import subprocess
|
||||
import sys
|
||||
import time
|
||||
import unittest
|
||||
from configparser import ConfigParser
|
||||
from functools import reduce
|
||||
from functools import wraps
|
||||
from itertools import chain
|
||||
@@ -24,7 +25,7 @@ from trytond.pool import Pool, isregisteredby
|
||||
from trytond import backend
|
||||
from trytond.model import Workflow, ModelSQL, ModelSingleton, ModelView, fields
|
||||
from trytond.model.fields import get_eval_fields, Function
|
||||
from trytond.tools import is_instance_method
|
||||
from trytond.tools import is_instance_method, file_open
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.cache import Cache
|
||||
from trytond.config import config, parse_uri
|
||||
@@ -633,6 +634,24 @@ class ModuleTestCase(unittest.TestCase):
|
||||
'keys': set(states) - keys,
|
||||
})
|
||||
|
||||
@with_transaction()
|
||||
def test_xml_files(self):
|
||||
"Test validity of the xml files of the module"
|
||||
config = ConfigParser()
|
||||
with file_open('%s/tryton.cfg' % self.module,
|
||||
subdir='modules', mode='r', encoding='utf-8') as fp:
|
||||
config.read_file(fp)
|
||||
if not config.has_option('tryton', 'xml'):
|
||||
return
|
||||
with file_open('tryton.rng', subdir='', mode='rb') as fp:
|
||||
rng = etree.parse(fp)
|
||||
validator = etree.RelaxNG(etree=rng)
|
||||
for xml_file in filter(None, config.get('tryton', 'xml').splitlines()):
|
||||
with file_open('%s/%s' % (self.module, xml_file),
|
||||
subdir='modules', mode='rb') as fp:
|
||||
tree = etree.parse(fp)
|
||||
validator.assertValid(tree)
|
||||
|
||||
|
||||
def db_exist(name=DB_NAME):
|
||||
Database = backend.get('Database')
|
||||
|
||||
+2
-1
@@ -7,7 +7,7 @@ attlist.data &=
|
||||
[ a:defaultValue = "0" ] attribute noupdate { "0" | "1" }?
|
||||
attlist.data &=
|
||||
[ a:defaultValue = "0" ] attribute grouped { "0" | "1" }?
|
||||
attlist.data &= attribute depends { text }
|
||||
attlist.data &= attribute depends { text }?
|
||||
record = element record { attlist.record, field* }
|
||||
attlist.record &= attribute model { text }
|
||||
attlist.record &= attribute id { text }
|
||||
@@ -20,6 +20,7 @@ attlist.field &= attribute ref { text }?
|
||||
attlist.field &= attribute eval { text }?
|
||||
attlist.field &= attribute pyson { "0" | "1" }?
|
||||
attlist.field &= attribute type { "xml" }?
|
||||
attlist.field &= attribute depends { text }?
|
||||
menuitem = element menuitem { attlist.menuitem, empty }
|
||||
attlist.menuitem &= attribute id { text }
|
||||
attlist.menuitem &= attribute name { text }?
|
||||
|
||||
+14
-4
@@ -48,10 +48,12 @@
|
||||
</optional>
|
||||
</define>
|
||||
<define name="attlist.data" combine="interleave">
|
||||
<attribute>
|
||||
<name ns="">depends</name>
|
||||
<text/>
|
||||
</attribute>
|
||||
<optional>
|
||||
<attribute>
|
||||
<name ns="">depends</name>
|
||||
<text/>
|
||||
</attribute>
|
||||
</optional>
|
||||
</define>
|
||||
<define name="record">
|
||||
<element>
|
||||
@@ -141,6 +143,14 @@
|
||||
</attribute>
|
||||
</optional>
|
||||
</define>
|
||||
<define name="attlist.field" combine="interleave">
|
||||
<optional>
|
||||
<attribute>
|
||||
<name ns="">depends</name>
|
||||
<text/>
|
||||
</attribute>
|
||||
</optional>
|
||||
</define>
|
||||
<define name="menuitem">
|
||||
<element>
|
||||
<name ns="">menuitem</name>
|
||||
|
||||
Reference in New Issue
Block a user