server/test/unittest_postgres.py
changeset 8139 f9ebb6d1abc3
parent 7228 9d04e12d2d39
child 8190 2a3c1b787688
equal deleted inserted replaced
8138:86da196640ae 8139:f9ebb6d1abc3
    30                                content=u'cubicweb')
    30                                content=u'cubicweb')
    31         c3 = req.create_entity('Card', title=u'c2',
    31         c3 = req.create_entity('Card', title=u'c2',
    32                                content=u'cubicweb cubicweb')
    32                                content=u'cubicweb cubicweb')
    33         self.commit()
    33         self.commit()
    34         self.assertEqual(req.execute('Card X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows,
    34         self.assertEqual(req.execute('Card X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows,
    35                           [[c1.eid], [c3.eid], [c2.eid]])
    35                          [(c1.eid,), (c3.eid,), (c2.eid,)])
    36 
    36 
    37 
    37 
    38     def test_attr_weight(self):
    38     def test_attr_weight(self):
    39         class CardIFTIndexableAdapter(IFTIndexableAdapter):
    39         class CardIFTIndexableAdapter(IFTIndexableAdapter):
    40             __select__ = is_instance('Card')
    40             __select__ = is_instance('Card')
    47                                    content=u'cubicweb cubicweb')
    47                                    content=u'cubicweb cubicweb')
    48             c3 = req.create_entity('Card', title=u'cubicweb',
    48             c3 = req.create_entity('Card', title=u'cubicweb',
    49                                    content=u'autre chose')
    49                                    content=u'autre chose')
    50             self.commit()
    50             self.commit()
    51             self.assertEqual(req.execute('Card X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows,
    51             self.assertEqual(req.execute('Card X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows,
    52                               [[c3.eid], [c1.eid], [c2.eid]])
    52                              [(c3.eid,), (c1.eid,), (c2.eid,)])
    53 
    53 
    54     def test_entity_weight(self):
    54     def test_entity_weight(self):
    55         class PersonneIFTIndexableAdapter(IFTIndexableAdapter):
    55         class PersonneIFTIndexableAdapter(IFTIndexableAdapter):
    56             __select__ = is_instance('Personne')
    56             __select__ = is_instance('Personne')
    57             entity_weight = 2.0
    57             entity_weight = 2.0
    60             c1 = req.create_entity('Personne', nom=u'c1', prenom=u'cubicweb')
    60             c1 = req.create_entity('Personne', nom=u'c1', prenom=u'cubicweb')
    61             c2 = req.create_entity('Comment', content=u'cubicweb cubicweb', comments=c1)
    61             c2 = req.create_entity('Comment', content=u'cubicweb cubicweb', comments=c1)
    62             c3 = req.create_entity('Comment', content=u'cubicweb cubicweb cubicweb', comments=c1)
    62             c3 = req.create_entity('Comment', content=u'cubicweb cubicweb cubicweb', comments=c1)
    63             self.commit()
    63             self.commit()
    64             self.assertEqual(req.execute('Any X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows,
    64             self.assertEqual(req.execute('Any X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows,
    65                               [[c1.eid], [c3.eid], [c2.eid]])
    65                               [(c1.eid,), (c3.eid,), (c2.eid,)])
    66 
    66 
    67 
    67 
    68     def test_tz_datetime(self):
    68     def test_tz_datetime(self):
    69         self.execute("INSERT Personne X: X nom 'bob', X tzdatenaiss %(date)s",
    69         self.execute("INSERT Personne X: X nom 'bob', X tzdatenaiss %(date)s",
    70                      {'date': datetime(1977, 6, 7, 2, 0, tzinfo=FixedOffset(1))})
    70                      {'date': datetime(1977, 6, 7, 2, 0, tzinfo=FixedOffset(1))})