[test] make unittest_postgres pass
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 27 Jan 2014 14:01:03 +0100
changeset 9499 872d16c04c79
parent 9498 a76ac18f09c4
child 9500 2735915bbc5d
[test] make unittest_postgres pass Use PostgresApptestConfiguration which starts a postgresql cluster locally for the duration of the test.
server/test/data/sources_postgres
server/test/unittest_postgres.py
--- a/server/test/data/sources_postgres	Tue Jan 28 15:03:53 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-[system]
-
-db-driver   = postgres
-db-host     = localhost
-db-port     = 5433
-adapter     = native
-db-name     = cw_fti_test
-db-encoding = UTF-8
-db-user     = syt
-db-password = syt
-
-[admin]
-login = admin
-password = gingkow
--- a/server/test/unittest_postgres.py	Tue Jan 28 15:03:53 2014 +0100
+++ b/server/test/unittest_postgres.py	Mon Jan 27 14:01:03 2014 +0100
@@ -16,27 +16,19 @@
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
 
-import socket
 from datetime import datetime
 
 from logilab.common.testlib import SkipTest
 
-from cubicweb.devtools import ApptestConfiguration
+from cubicweb.devtools import PostgresApptestConfiguration
 from cubicweb.devtools.testlib import CubicWebTC
 from cubicweb.predicates import is_instance
 from cubicweb.entities.adapters import IFTIndexableAdapter
 
-AT_LOGILAB = socket.gethostname().endswith('.logilab.fr') # XXX
-
 from unittest_querier import FixedOffset
 
 class PostgresFTITC(CubicWebTC):
-    @classmethod
-    def setUpClass(cls):
-        if not AT_LOGILAB: # XXX here until we can raise SkipTest in setUp to detect we can't connect to the db
-            raise SkipTest('XXX %s: require logilab configuration' % cls.__name__)
-        cls.config = ApptestConfiguration('data', sourcefile='sources_postgres',
-                                          apphome=cls.datadir)
+    configcls = PostgresApptestConfiguration
 
     def test_occurence_count(self):
         req = self.request()
@@ -48,7 +40,7 @@
                                content=u'cubicweb cubicweb')
         self.commit()
         self.assertEqual(req.execute('Card X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows,
-                         [(c1.eid,), (c3.eid,), (c2.eid,)])
+                         [[c1.eid,], [c3.eid,], [c2.eid,]])
 
 
     def test_attr_weight(self):
@@ -65,7 +57,7 @@
                                    content=u'autre chose')
             self.commit()
             self.assertEqual(req.execute('Card X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows,
-                             [(c3.eid,), (c1.eid,), (c2.eid,)])
+                             [[c3.eid,], [c1.eid,], [c2.eid,]])
 
     def test_entity_weight(self):
         class PersonneIFTIndexableAdapter(IFTIndexableAdapter):
@@ -78,7 +70,7 @@
             c3 = req.create_entity('Comment', content=u'cubicweb cubicweb cubicweb', comments=c1)
             self.commit()
             self.assertEqual(req.execute('Any X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows,
-                              [(c1.eid,), (c3.eid,), (c2.eid,)])
+                              [[c1.eid,], [c3.eid,], [c2.eid,]])
 
 
     def test_tz_datetime(self):