diff -r c739ebc18b79 -r 59626567eade web/test/unittest_reledit.py --- a/web/test/unittest_reledit.py Fri Apr 04 11:31:39 2014 +0200 +++ b/web/test/unittest_reledit.py Thu Apr 03 18:35:18 2014 +0200 @@ -25,10 +25,11 @@ class ReleditMixinTC(object): def setup_database(self): - self.req = self.request() - self.proj = self.req.create_entity('Project', title=u'cubicweb-world-domination') - self.tick = self.req.create_entity('Ticket', title=u'write the code') - self.toto = self.req.create_entity('Personne', nom=u'Toto') + 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): @@ -39,13 +40,16 @@ '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 reledit: - continue - rtype = rschema.type - self.assertMultiLineEqual(reledit[rtype] % {'eid': self.proj.eid}, - self.proj.view('reledit', rtype=rtype, role=role), - rtype) + 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') @@ -175,8 +179,10 @@ def setup_database(self): super(ClickAndEditFormUICFGTC, self).setup_database() - self.tick.cw_set(concerns=self.proj) - self.proj.cw_set(manager=self.toto) + 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() @@ -198,13 +204,15 @@ 'composite_card11_2ttypes': """<not specified>""", 'concerns': """
write the code
""" } - for rschema, ttypes, role in self.proj.e_schema.relation_definitions(includefinal=True): - if rschema not in reledit: - continue - rtype = rschema.type - self.assertMultiLineEqual(reledit[rtype] % {'eid': self.proj.eid, 'toto': self.toto.eid, 'tick': self.tick.eid}, - self.proj.view('reledit', rtype=rtype, role=role), - rtype) + 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, 'toto': self.toto, 'tick': self.tick}, + proj.view('reledit', rtype=rtype, role=role), + rtype) reledit_ctrl.clear() reledit_ctrl._tagdefs.update(old_rctl)