# HG changeset patch # User Sylvain Thénault # Date 1250783426 -7200 # Node ID b97a0f8dd4dcb5155dae17ccc5d5dabdbac25921 # Parent 996103009bc501988c73dec7b10ec34f35628f02 fix test schema and update some tests to work again with wf changes diff -r 996103009bc5 -r b97a0f8dd4dc server/test/data/schema.py --- a/server/test/data/schema.py Thu Aug 20 17:49:31 2009 +0200 +++ b/server/test/data/schema.py Thu Aug 20 17:50:26 2009 +0200 @@ -34,7 +34,7 @@ depends_on = SubjectRelation('Affaire') require_permission = SubjectRelation('CWPermission') concerne = SubjectRelation(('Societe', 'Note')) - todo_by = SubjectRelation('Personne') + todo_by = SubjectRelation('Personne', cardinality='?*') documented_by = SubjectRelation('Card') diff -r 996103009bc5 -r b97a0f8dd4dc server/test/unittest_hooks.py --- a/server/test/unittest_hooks.py Thu Aug 20 17:49:31 2009 +0200 +++ b/server/test/unittest_hooks.py Thu Aug 20 17:50:26 2009 +0200 @@ -60,18 +60,6 @@ self.assertRaises(ValidationError, self.commit) - def test_delete_if_singlecard1(self): - self.assertEquals(self.repo.schema['in_state'].inlined, False) - ueid = self.create_user('toto') - self.commit() - self.execute('SET X in_state S WHERE S name "deactivated", X eid %(x)s', {'x': ueid}) - rset = self.execute('Any S WHERE X in_state S, X eid %(x)s', {'x': ueid}) - self.assertEquals(len(rset), 1) - self.commit() - self.assertRaises(Exception, self.execute, 'SET X in_state S WHERE S name "deactivated", X eid %s' % ueid) - rset2 = self.execute('Any S WHERE X in_state S, X eid %(x)s', {'x': ueid}) - self.assertEquals(rset.rows, rset2.rows) - def test_inlined(self): self.assertEquals(self.repo.schema['sender'].inlined, True) self.execute('INSERT EmailAddress X: X address "toto@logilab.fr", X alias "hop"') diff -r 996103009bc5 -r b97a0f8dd4dc server/test/unittest_repository.py --- a/server/test/unittest_repository.py Thu Aug 20 17:49:31 2009 +0200 +++ b/server/test/unittest_repository.py Thu Aug 20 17:50:26 2009 +0200 @@ -339,6 +339,22 @@ # self.set_debug(False) # print 'test time: %.3f (time) %.3f (cpu)' % ((time() - t), clock() - c) + def test_delete_if_singlecard1(self): + note = self.add_entity('Affaire') + p1 = self.add_entity('Personne', nom=u'toto') + self.execute('SET A todo_by P WHERE A eid %(x)s, P eid %(p)s', + {'x': note.eid, 'p': p1.eid}) + rset = self.execute('Any P WHERE A todo_by P, A eid %(x)s', + {'x': note.eid}) + self.assertEquals(len(rset), 1) + p2 = self.add_entity('Personne', nom=u'tutu') + self.execute('SET A todo_by P WHERE A eid %(x)s, P eid %(p)s', + {'x': note.eid, 'p': p2.eid}) + rset = self.execute('Any P WHERE A todo_by P, A eid %(x)s', + {'x': note.eid}) + self.assertEquals(len(rset), 1) + self.assertEquals(rset.rows[0][0], p2.eid) + class DataHelpersTC(RepositoryBasedTC): @@ -482,11 +498,11 @@ def test_after_add_inline(self): """make sure after__relation hooks are deferred""" + p1 = self.add_entity('Personne', nom=u'toto') self.hm.register_hook(self._after_relation_hook, - 'after_add_relation', 'in_state') - eidp = self.execute('INSERT CWUser X: X login "toto", X upassword "tutu", X in_state S WHERE S name "activated"')[0][0] - eids = self.execute('State X WHERE X name "activated"')[0][0] - self.assertEquals(self.called, [(eidp, 'in_state', eids,)]) + 'after_add_relation', 'ecrit_par') + eidn = self.execute('INSERT Note N: N ecrit_par P WHERE P nom "toto"')[0][0] + self.assertEquals(self.called, [(eidn, 'ecrit_par', p1.eid,)]) def test_before_delete_inline_relation(self): """make sure before__relation hooks are called directly""" diff -r 996103009bc5 -r b97a0f8dd4dc server/test/unittest_ssplanner.py --- a/server/test/unittest_ssplanner.py Thu Aug 20 17:49:31 2009 +0200 +++ b/server/test/unittest_ssplanner.py Thu Aug 20 17:50:26 2009 +0200 @@ -9,7 +9,7 @@ from cubicweb.devtools.repotest import BasePlannerTC, test_plan from cubicweb.server.ssplanner import SSPlanner -# keep cnx so it's not garbage collected and the associated session is closed +# keep cnx so it's not garbage collected and the associated session closed repo, cnx = init_test_database('sqlite') class SSPlannerTC(BasePlannerTC):