ajay javiya (OpenERP) has proposed merging 
lp:~openerp-commiter/openobject-server/trunk-sloppy-rng-jam-fix-aja into 
lp:~openerp-dev/openobject-server/trunk-sloppy-rng-jam.

Requested reviews:
  Jigar Amin  (OpenERP) (jam-openerp)

For more details, see:
https://code.launchpad.net/~openerp-commiter/openobject-server/trunk-sloppy-rng-jam-fix-aja/+merge/116810

Hello,
Improve in view_validation and remove valid_att_in_graph and valid_att_in_tree 
functions.
Thank You
-- 
https://code.launchpad.net/~openerp-commiter/openobject-server/trunk-sloppy-rng-jam-fix-aja/+merge/116810
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-server/trunk-sloppy-rng-jam.
=== modified file 'openerp/tests/test_view_validation.py'
--- openerp/tests/test_view_validation.py	2012-07-03 08:46:20 +0000
+++ openerp/tests/test_view_validation.py	2012-07-26 09:12:18 +0000
@@ -14,7 +14,7 @@
     <group>
         <div>
             <page></page>
-            <label colspan="True"> </label>
+            <label colspan="True"></label>
             <field></field>
         </div>
     </group>
@@ -118,8 +118,8 @@
         assert not valid_att_in_form(invalid_form)
         assert valid_att_in_form(valid_form)
 
-        assert not valid_form_view(invalid_form)
-        assert valid_form_view(valid_form)
+        assert not valid_view(invalid_form)
+        assert valid_view(valid_form)
 
     def test_graph_field_validation(self):
         assert not valid_field_in_graph(invalid_graph)
@@ -129,11 +129,11 @@
         assert valid_view(valid_graph)        
 
     def test_graph_string_validation(self):
-        assert not valid_att_in_graph(invalid_graph)
-        assert valid_att_in_graph(valid_graph)
+        assert not valid_field_in_graph(invalid_graph)
+        assert valid_field_in_graph(valid_graph)
 
-        assert not valid_graph_view(invalid_graph)
-        assert valid_graph_view(valid_graph)
+        assert not valid_view(invalid_graph)
+        assert valid_view(valid_graph)
     
     def test_tree_field_validation(self):
         assert not valid_field_in_tree(invalid_tree)
@@ -143,11 +143,11 @@
         assert valid_view(valid_tree)        
 
     def test_tree_string_validation(self):
-        assert not valid_att_in_tree(invalid_tree)
-        assert valid_att_in_tree(valid_tree)
+        assert not valid_field_in_tree(invalid_tree)
+        assert valid_field_in_tree(valid_tree)
     
-        assert not valid_tree_view(invalid_tree)
-        assert valid_tree_view(valid_tree)
+        assert not valid_view(invalid_tree)
+        assert valid_view(valid_tree)
         
     def test_colspan_datatype_validation(self):
         assert not valid_type_in_colspan(invalid_form)

=== modified file 'openerp/tools/view_validation.py'
--- openerp/tools/view_validation.py	2012-07-03 08:51:27 +0000
+++ openerp/tools/view_validation.py	2012-07-26 09:12:18 +0000
@@ -6,11 +6,11 @@
 
 def valid_field_in_graph(arch):
     """A `field` node must be below a `graph` node."""
-    return not arch.xpath('//graph[not(field)]')
+    return not arch.xpath('//graph[not ((field) and (@string))]')
 
 def valid_field_in_tree(arch):
     """A `field` and `button` node must be below a `tree` node."""
-    return not arch.xpath('//tree[not((field) and (button))]')
+    return not arch.xpath('//tree[not((field) and (button) and (@string))]')
 
 def valid_att_in_field(arch):
     """A `name` attribute must be in a `field` node."""
@@ -19,19 +19,11 @@
 def valid_att_in_label(arch):
     """A `for` and `string` attribute must be in a `label` node."""
     return not arch.xpath('//label[not ((@for) or (@string))]')
-    
-def valid_att_in_tree(arch):
-    """A `string` attribute must be in a `tree` node."""
-    return not arch.xpath('//tree[not (@string)]')
 
 def valid_att_in_form(arch):
     """A `string` attribute must be in a `form` node."""
     return not arch.xpath('//form[not (@string)]')
 
-def valid_att_in_graph(arch):
-    """A `string` attribute must be in a `graph` node."""
-    return not arch.xpath('//graph[not (@string)]')
-
 def valid_type_in_colspan(arch):
     """A `colspan` attribute must be an `integer` type."""
     for attrib in arch.xpath('//*/@colspan'):
@@ -73,32 +65,10 @@
             if not pred(arch):
                 return False
         return True
-
-def valid_tree_view(arch):
-    if arch.tag == 'tree':
-        for pred in [valid_att_in_tree]:
-            if not pred(arch):
-                return False
-    return True
-
-def valid_form_view(arch):
-    if arch.tag == 'form':
-        for pred in [valid_att_in_form]:
-            if not pred(arch):
-                return False
-    return True
-
-def valid_graph_view(arch):
-    if arch.tag == 'graph':
-        for pred in [valid_att_in_graph]:
-            if not pred(arch):
-                return False
-    return True
-
     
 def valid_view(arch):
     if arch.tag == 'form':
-        for pred in [valid_page_in_book]:
+        for pred in [valid_page_in_book,valid_att_in_form]:
             if not pred(arch):
                 return False
     elif arch.tag == 'graph':

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to