# HG changeset patch # User Julien Cristau # Date 1390827663 -3600 # Node ID 872d16c04c7921b86ba26dd541bee7c8c0ed7d50 # Parent a76ac18f09c4da6bf223078b3e8ce80a5d0b7fff [test] make unittest_postgres pass Use PostgresApptestConfiguration which starts a postgresql cluster locally for the duration of the test. diff -r a76ac18f09c4 -r 872d16c04c79 server/test/data/sources_postgres --- 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 diff -r a76ac18f09c4 -r 872d16c04c79 server/test/unittest_postgres.py --- 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 . -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):