--- a/web/test/unittest_uicfg.py Wed Jun 30 15:50:06 2010 +0200
+++ b/web/test/unittest_uicfg.py Tue Jun 22 13:47:13 2010 +0200
@@ -15,6 +15,7 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
+from logilab.common.testlib import tag
from cubicweb.devtools.testlib import CubicWebTC
from cubicweb.web import uicfg
@@ -25,6 +26,57 @@
def test_default_actionbox_appearsin_addmenu_config(self):
self.failIf(abaa.etype_get('TrInfo', 'wf_info_for', 'object', 'CWUser'))
+
+
+class DefinitionOrderTC(CubicWebTC):
+ """This test check that when multiple definition could match a key, only
+ the more accurate apply"""
+
+ def setUp(self):
+
+ new_def = (
+ (('*', 'login', '*'),
+ {'formtype':'main', 'section':'hidden'}),
+ (('*', 'login', '*'),
+ {'formtype':'muledit', 'section':'hidden'}),
+ (('CWUser', 'login', '*'),
+ {'formtype':'main', 'section':'attributes'}),
+ (('CWUser', 'login', '*'),
+ {'formtype':'muledit', 'section':'attributes'}),
+ (('CWUser', 'login', 'String'),
+ {'formtype':'main', 'section':'inlined'}),
+ (('CWUser', 'login', 'String'),
+ {'formtype':'inlined', 'section':'attributes'}),
+ )
+ self._old_def = []
+
+ for key, kwargs in new_def:
+ nkey = key[0], key[1], key[2], 'subject'
+ self._old_def.append((nkey, uicfg.autoform_section._tagdefs.get(nkey)))
+ uicfg.autoform_section.tag_subject_of(key, **kwargs)
+
+ super(DefinitionOrderTC, self).setUp()
+
+
+ @tag('uicfg')
+ def test_definition_order_hidden(self):
+ result = uicfg.autoform_section.get('CWUser', 'login', 'String', 'subject')
+ expected = set(['main_inlined', 'muledit_attributes', 'inlined_attributes'])
+ self.assertSetEquals(result, expected)
+
+ def tearDown(self):
+ super(DefinitionOrderTC, self).tearDown()
+ for key, tags in self._old_def:
+ if tags is None:
+ uicfg.autoform_section.del_rtag(*key)
+ else:
+ for tag in tags:
+ formtype, section = tag.split('_')
+ uicfg.autoform_section.tag_subject_of(key[:3], formtype=formtype, section=section)
+
+ uicfg.autoform_section.clear()
+ uicfg.autoform_section.init(self.repo.vreg.schema)
+
if __name__ == '__main__':
from logilab.common.testlib import unittest_main
unittest_main()