tests update 3.5
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 16 Sep 2009 16:37:49 +0200
branch3.5
changeset 3252 c0e10da6f1cf
parent 3251 7ff4754f8618
child 3253 905e269ff853
tests update
server/test/unittest_migractions.py
server/test/unittest_multisources.py
server/test/unittest_security.py
server/test/unittest_ssplanner.py
--- a/server/test/unittest_migractions.py	Wed Sep 16 16:37:27 2009 +0200
+++ b/server/test/unittest_migractions.py	Wed Sep 16 16:37:49 2009 +0200
@@ -141,10 +141,11 @@
 
     def test_add_drop_entity_type(self):
         self.mh.cmd_add_entity_type('Folder2')
-        todoeid = self.mh.cmd_add_state(u'todo', 'Folder2', initial=True)
-        doneeid = self.mh.cmd_add_state(u'done', 'Folder2')
-        self.mh.cmd_add_transition(u'redoit', 'Folder2', (doneeid,), todoeid)
-        self.mh.cmd_add_transition(u'markasdone', 'Folder2', (todoeid,), doneeid)
+        wf = self.mh.cmd_add_workflow(u'folder2 wf', 'Folder2')
+        todo = wf.add_state(u'todo', initial=True)
+        done = wf.add_state(u'done')
+        wf.add_transition(u'redoit', done, todo)
+        wf.add_transition(u'markasdone', todo, done)
         self.commit()
         eschema = self.schema.eschema('Folder2')
         self.mh.cmd_drop_entity_type('Folder2')
@@ -175,8 +176,8 @@
                           '1*')
         self.mh.cmd_add_relation_definition('Personne', 'concerne2', 'Note')
         self.assertEquals(sorted(self.schema['concerne2'].objects()), ['Affaire', 'Note'])
-        self.mh.add_entity('Personne', nom=u'tot')
-        self.mh.add_entity('Affaire')
+        self.mh.create_entity('Personne', nom=u'tot')
+        self.mh.create_entity('Affaire')
         self.mh.rqlexec('SET X concerne2 Y WHERE X is Personne, Y is Affaire')
         self.commit()
         self.mh.cmd_drop_relation_definition('Personne', 'concerne2', 'Affaire')
@@ -443,12 +444,6 @@
         ex = self.assertRaises(ConfigurationError, self.mh.cmd_remove_cube, 'file')
         self.assertEquals(str(ex), "can't remove cube file, used as a dependency")
 
-    def test_set_state(self):
-        user = self.session.user
-        self.mh.set_state(user.eid, 'deactivated')
-        user.clear_related_cache('in_state', 'subject')
-        self.assertEquals(user.state, 'deactivated')
-
     def test_introduce_base_class(self):
         self.mh.cmd_add_entity_type('Para')
         self.mh.repo.schema.rebuild_infered_relations()
--- a/server/test/unittest_multisources.py	Wed Sep 16 16:37:27 2009 +0200
+++ b/server/test/unittest_multisources.py	Wed Sep 16 16:37:49 2009 +0200
@@ -233,11 +233,12 @@
 
     def test_not_relation(self):
         states = set(tuple(x) for x in self.execute('Any S,SN WHERE S is State, S name SN'))
+        self.session.user.clear_all_caches()
         userstate = self.session.user.in_state[0]
         states.remove((userstate.eid, userstate.name))
         notstates = set(tuple(x) for x in self.execute('Any S,SN WHERE S is State, S name SN, NOT X in_state S, X eid %(x)s',
                                                        {'x': self.session.user.eid}, 'x'))
-        self.assertEquals(notstates, states)
+        self.assertSetEquals(notstates, states)
         aff1 = self.execute('Any X WHERE X is Affaire, X ref "AFFREF"')[0][0]
         aff1stateeid, aff1statename = self.execute('Any S,SN WHERE X eid %(x)s, X in_state S, S name SN', {'x': aff1}, 'x')[0]
         self.assertEquals(aff1statename, 'pitetre')
--- a/server/test/unittest_security.py	Wed Sep 16 16:37:27 2009 +0200
+++ b/server/test/unittest_security.py	Wed Sep 16 16:37:49 2009 +0200
@@ -27,10 +27,10 @@
 
     def test_check_read_access(self):
         rql = u'Personne U where U nom "managers"'
-        rqlst = self.repo.querier._rqlhelper.parse(rql).children[0]
+        rqlst = self.repo.vreg.rqlhelper.parse(rql).children[0]
         origgroups = self.schema['Personne'].get_groups('read')
         self.schema['Personne'].set_groups('read', ('users', 'managers'))
-        self.repo.querier._rqlhelper.compute_solutions(rqlst)
+        self.repo.vreg.rqlhelper.compute_solutions(rqlst)
         solution = rqlst.solutions[0]
         check_read_access(self.schema, self.session.user, rqlst, solution)
         cnx = self.login('anon')
--- a/server/test/unittest_ssplanner.py	Wed Sep 16 16:37:27 2009 +0200
+++ b/server/test/unittest_ssplanner.py	Wed Sep 16 16:37:49 2009 +0200
@@ -18,7 +18,7 @@
 
     def setUp(self):
         BasePlannerTC.setUp(self)
-        self.planner = SSPlanner(self.o.schema, self.o._rqlhelper)
+        self.planner = SSPlanner(self.o.schema, self.repo.vreg.rqlhelper)
         self.system = self.o._repo.system_source
 
     def tearDown(self):