diff -r 058bb3dc685f -r 0b59724cb3f2 cubicweb/web/test/unittest_reledit.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/web/test/unittest_reledit.py Sat Jan 16 13:48:51 2016 +0100
@@ -0,0 +1,225 @@
+# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
+#
+# This file is part of CubicWeb.
+#
+# CubicWeb is free software: you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation, either version 2.1 of the License, or (at your option)
+# any later version.
+#
+# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with CubicWeb. If not, see .
+"""
+mainly regression-preventing tests for reledit views
+"""
+
+from cubicweb.devtools.testlib import CubicWebTC
+from cubicweb.web.views.uicfg import reledit_ctrl
+
+class ReleditMixinTC(object):
+
+ def setup_database(self):
+ with self.admin_access.client_cnx() as cnx:
+ self.proj = cnx.create_entity('Project', title=u'cubicweb-world-domination').eid
+ self.tick = cnx.create_entity('Ticket', title=u'write the code').eid
+ self.toto = cnx.create_entity('Personne', nom=u'Toto').eid
+ cnx.commit()
+
+class ClickAndEditFormTC(ReleditMixinTC, CubicWebTC):
+
+ def test_default_config(self):
+ reledit = {'title': '''
cubicweb-world-domination
''',
+ 'long_desc': '''
<not specified>
''',
+ 'manager': '''
<not specified>
''',
+ 'composite_card11_2ttypes': """<not specified>""",
+ 'concerns': """<not specified>"""}
+
+ with self.admin_access.web_request() as req:
+ proj = req.entity_from_eid(self.proj)
+
+ for rschema, ttypes, role in proj.e_schema.relation_definitions(includefinal=True):
+ if rschema not in reledit:
+ continue
+ rtype = rschema.type
+ self.assertMultiLineEqual(reledit[rtype] % {'eid': self.proj},
+ proj.view('reledit', rtype=rtype, role=role),
+ rtype)
+
+ def test_default_forms(self):
+ self.skipTest('Need to check if this test should still run post reledit/doreledit merge')
+ doreledit = {'title': """
cubicweb-world-domination
""",
+
+ 'long_desc': """
<not specified>
""",
+
+ 'manager': """
<not specified>
""",
+ 'composite_card11_2ttypes': """<not specified>""",
+ 'concerns': """<not specified>"""
+ }
+ for rschema, ttypes, role in self.proj.e_schema.relation_definitions(includefinal=True):
+ if rschema not in doreledit:
+ continue
+ rtype = rschema.type
+ self.assertMultiLineEqual(doreledit[rtype] % {'eid': self.proj.eid, 'toto': self.toto.eid},
+ self.proj.view('doreledit', rtype=rtype, role=role,
+ formid='edition' if rtype == 'long_desc' else 'base'),
+ rtype)
+
+class ClickAndEditFormUICFGTC(ReleditMixinTC, CubicWebTC):
+
+ def setup_database(self):
+ super(ClickAndEditFormUICFGTC, self).setup_database()
+ with self.admin_access.client_cnx() as cnx:
+ cnx.execute('SET T concerns P WHERE T eid %(t)s, P eid %(p)s', {'t': self.tick, 'p': self.proj})
+ cnx.execute('SET P manager T WHERE P eid %(p)s, T eid %(t)s', {'p': self.proj, 't': self.toto})
+ cnx.commit()
+
+ def test_with_uicfg(self):
+ old_rctl = reledit_ctrl._tagdefs.copy()
+ reledit_ctrl.tag_attribute(('Project', 'title'),
+ {'novalue_label': '', 'reload': True})
+ reledit_ctrl.tag_subject_of(('Project', 'long_desc', '*'),
+ {'reload': True, 'edit_target': 'rtype',
+ 'novalue_label': u''})
+ reledit_ctrl.tag_subject_of(('Project', 'manager', '*'),
+ {'edit_target': 'related'})
+ reledit_ctrl.tag_subject_of(('Project', 'composite_card11_2ttypes', '*'),
+ {'edit_target': 'related'})
+ reledit_ctrl.tag_object_of(('Ticket', 'concerns', 'Project'),
+ {'edit_target': 'rtype'})
+ reledit = {
+ 'title': """