[test] Drop no more used "maxeid" based deletion in BaseQuerierTC and derived tests
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 03 Nov 2017 16:31:59 +0100
changeset 12237 2dd0dcb2e5f9
parent 12236 75a6b2f40c44
child 12238 6ed86e0b0222
[test] Drop no more used "maxeid" based deletion in BaseQuerierTC and derived tests This is probably only necessary for QuerierTC itself, move it there and drop incantation from other derived classes to deactivate this feature.
cubicweb/devtools/repotest.py
cubicweb/server/test/unittest_migractions.py
cubicweb/server/test/unittest_querier.py
cubicweb/server/test/unittest_rqlannotation.py
cubicweb/server/test/unittest_ssplanner.py
--- a/cubicweb/devtools/repotest.py	Fri Sep 15 16:31:33 2017 +0200
+++ b/cubicweb/devtools/repotest.py	Fri Nov 03 16:31:59 2017 +0100
@@ -142,22 +142,11 @@
         self.ueid = self.admin_access._user.eid
         assert self.ueid != -1
         self.repo._type_cache = {} # clear cache
-        self.maxeid = self.get_max_eid()
         do_monkey_patch()
         self._dumb_sessions = []
 
-    def get_max_eid(self):
-        with self.admin_access.cnx() as cnx:
-            return cnx.execute('Any MAX(X)')[0][0]
-
-    def cleanup(self):
-        with self.admin_access.cnx() as cnx:
-            cnx.execute('DELETE Any X WHERE X eid > %s' % self.maxeid)
-            cnx.commit()
-
     def tearDown(self):
         undo_monkey_patch()
-        self.cleanup()
         assert self.admin_access._user.eid != -1
 
     def set_debug(self, debug):
--- a/cubicweb/server/test/unittest_migractions.py	Fri Sep 15 16:31:33 2017 +0200
+++ b/cubicweb/server/test/unittest_migractions.py	Fri Nov 03 16:31:59 2017 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -728,9 +728,6 @@
             finally:
                 mh.cmd_add_cube('fakeemail')
                 self.assertIn('fakeemail', self.config.cubes())
-                # trick: overwrite self.maxeid to avoid deletion of just reintroduced
-                #        types (and their associated tables!)
-                self.maxeid = cnx.execute('Any MAX(X)')[0][0] # XXXXXXX KILL KENNY
                 # why this commit is necessary is unclear to me (though without it
                 # next test may fail complaining of missing tables
                 cnx.commit()
--- a/cubicweb/server/test/unittest_querier.py	Fri Sep 15 16:31:33 2017 +0200
+++ b/cubicweb/server/test/unittest_querier.py	Fri Nov 03 16:31:59 2017 +0100
@@ -1,5 +1,5 @@
 # -*- coding: iso-8859-1 -*-
-# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -112,13 +112,6 @@
     setUpClass = classmethod(setUpClass)
     tearDownClass = classmethod(tearDownClass)
 
-    def get_max_eid(self):
-        # no need for cleanup here
-        return None
-    def cleanup(self):
-        # no need for cleanup here
-        pass
-
     def test_preprocess_1(self):
         with self.admin_access.cnx() as cnx:
             reid = cnx.execute('Any X WHERE X is CWRType, X name "owned_by"')[0][0]
@@ -316,6 +309,17 @@
     setUpClass = classmethod(setUpClass)
     tearDownClass = classmethod(tearDownClass)
 
+    def setUp(self):
+        super(QuerierTC, self).setUp()
+        with self.admin_access.cnx() as cnx:
+            self.maxeid = cnx.execute('Any MAX(X)')[0][0]
+
+    def tearDown(self):
+        super(QuerierTC, self).tearDown()
+        with self.admin_access.cnx() as cnx:
+            cnx.execute('DELETE Any X WHERE X eid > %s' % self.maxeid)
+            cnx.commit()
+
     def test_unknown_eid(self):
         # should return an empty result set
         self.assertFalse(self.qexecute('Any X WHERE X eid 99999999'))
--- a/cubicweb/server/test/unittest_rqlannotation.py	Fri Sep 15 16:31:33 2017 +0200
+++ b/cubicweb/server/test/unittest_rqlannotation.py	Fri Nov 03 16:31:59 2017 +0100
@@ -1,5 +1,5 @@
 # -*- coding: iso-8859-1 -*-
-# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -31,14 +31,6 @@
         self.__class__.repo = repo
         super(SQLGenAnnotatorTC, self).setUp()
 
-    def get_max_eid(self):
-        # no need for cleanup here
-        return None
-
-    def cleanup(self):
-        # no need for cleanup here
-        pass
-
     def test_0_1(self):
         with self.admin_access.cnx() as cnx:
             rqlst = self._prepare(cnx, 'Any SEN,RN,OEN WHERE X from_entity SE, '
--- a/cubicweb/server/test/unittest_ssplanner.py	Fri Sep 15 16:31:33 2017 +0200
+++ b/cubicweb/server/test/unittest_ssplanner.py	Fri Nov 03 16:31:59 2017 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -44,9 +44,6 @@
         self.planner = SSPlanner(self.o.schema, self.repo.vreg.rqlhelper)
         self.system = self.o._repo.system_source
 
-    def tearDown(self):
-        BasePlannerTC.tearDown(self)
-
     def test_ordered_ambigous_sol(self):
         self._test('Any XN ORDERBY XN WHERE X name XN, X is IN (Basket, State, Folder)',
                    [('OneFetchStep', [('Any XN ORDERBY XN WHERE X name XN, X is IN(Basket, State, Folder)',