server/test/unittest_postgres.py
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 28 May 2014 17:57:40 +0200
changeset 9783 59c582ce68c8
parent 9585 3f5b59527d31
child 9804 fe9ae959da08
permissions -rw-r--r--
[tests/storage] use the new connection api
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9585
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
     1
# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
8343
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
     3
#
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
     4
# This file is part of CubicWeb.
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
     5
#
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
     9
# any later version.
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
    10
#
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
    14
# details.
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
    15
#
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
6bd8db130476 Fix a Python 2.5 regression introduced by previous commit
David Douard <david.douard@logilab.fr>
parents: 7228
diff changeset
    18
7166
dde161937d3e [time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6818
diff changeset
    19
from datetime import datetime
9585
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    20
from threading import Thread
6206
d4c73211b0b8 [test] skip unittest_fti if we don't have the required setup...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5877
diff changeset
    21
6818
5fa425574548 [server test] can't use skipTest method as a class method, raise appropriate exception instead
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6780
diff changeset
    22
from logilab.common.testlib import SkipTest
5fa425574548 [server test] can't use skipTest method as a class method, raise appropriate exception instead
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6780
diff changeset
    23
9499
872d16c04c79 [test] make unittest_postgres pass
Julien Cristau <julien.cristau@logilab.fr>
parents: 8694
diff changeset
    24
from cubicweb.devtools import PostgresApptestConfiguration
5768
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    25
from cubicweb.devtools.testlib import CubicWebTC
8190
2a3c1b787688 [vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8139
diff changeset
    26
from cubicweb.predicates import is_instance
5768
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    27
from cubicweb.entities.adapters import IFTIndexableAdapter
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    28
7166
dde161937d3e [time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6818
diff changeset
    29
from unittest_querier import FixedOffset
6780
92e4c07f86c0 [server/test] raise SkipTest from setUpModule instead of setUp( unittest2 behaviour) + kill some deprecation warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6436
diff changeset
    30
5768
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    31
class PostgresFTITC(CubicWebTC):
9499
872d16c04c79 [test] make unittest_postgres pass
Julien Cristau <julien.cristau@logilab.fr>
parents: 8694
diff changeset
    32
    configcls = PostgresApptestConfiguration
6206
d4c73211b0b8 [test] skip unittest_fti if we don't have the required setup...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5877
diff changeset
    33
9585
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    34
    def test_eid_range(self):
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    35
        # concurrent allocation of eid ranges
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    36
        source = self.session.repo.sources_by_uri['system']
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    37
        range1 = []
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    38
        range2 = []
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    39
        def allocate_eid_ranges(session, target):
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    40
            for x in xrange(1, 10):
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    41
                eid = source.create_eid(session, count=x)
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    42
                target.extend(range(eid-x, eid))
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    43
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    44
        t1 = Thread(target=lambda: allocate_eid_ranges(self.session, range1))
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    45
        t2 = Thread(target=lambda: allocate_eid_ranges(self.session, range2))
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    46
        t1.start()
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    47
        t2.start()
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    48
        t1.join()
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    49
        t2.join()
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    50
        self.assertEqual(range1, sorted(range1))
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    51
        self.assertEqual(range2, sorted(range2))
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    52
        self.assertEqual(set(), set(range1) & set(range2))
3f5b59527d31 [source/native] allow many eid creation per .create_eid call (closes #3526594)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9499
diff changeset
    53
5768
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    54
    def test_occurence_count(self):
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    55
        req = self.request()
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    56
        c1 = req.create_entity('Card', title=u'c1',
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    57
                               content=u'cubicweb cubicweb cubicweb')
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    58
        c2 = req.create_entity('Card', title=u'c3',
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    59
                               content=u'cubicweb')
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    60
        c3 = req.create_entity('Card', title=u'c2',
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    61
                               content=u'cubicweb cubicweb')
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    62
        self.commit()
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6206
diff changeset
    63
        self.assertEqual(req.execute('Card X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows,
9499
872d16c04c79 [test] make unittest_postgres pass
Julien Cristau <julien.cristau@logilab.fr>
parents: 8694
diff changeset
    64
                         [[c1.eid,], [c3.eid,], [c2.eid,]])
5768
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    65
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    66
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    67
    def test_attr_weight(self):
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    68
        class CardIFTIndexableAdapter(IFTIndexableAdapter):
5877
0c7b7b76a84f [selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5768
diff changeset
    69
            __select__ = is_instance('Card')
5768
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    70
            attr_weight = {'title': 'A'}
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    71
        with self.temporary_appobjects(CardIFTIndexableAdapter):
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    72
            req = self.request()
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    73
            c1 = req.create_entity('Card', title=u'c1',
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    74
                                   content=u'cubicweb cubicweb cubicweb')
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    75
            c2 = req.create_entity('Card', title=u'c2',
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    76
                                   content=u'cubicweb cubicweb')
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    77
            c3 = req.create_entity('Card', title=u'cubicweb',
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    78
                                   content=u'autre chose')
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    79
            self.commit()
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6206
diff changeset
    80
            self.assertEqual(req.execute('Card X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows,
9499
872d16c04c79 [test] make unittest_postgres pass
Julien Cristau <julien.cristau@logilab.fr>
parents: 8694
diff changeset
    81
                             [[c3.eid,], [c1.eid,], [c2.eid,]])
5768
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    82
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    83
    def test_entity_weight(self):
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    84
        class PersonneIFTIndexableAdapter(IFTIndexableAdapter):
5877
0c7b7b76a84f [selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5768
diff changeset
    85
            __select__ = is_instance('Personne')
5768
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    86
            entity_weight = 2.0
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    87
        with self.temporary_appobjects(PersonneIFTIndexableAdapter):
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    88
            req = self.request()
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    89
            c1 = req.create_entity('Personne', nom=u'c1', prenom=u'cubicweb')
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    90
            c2 = req.create_entity('Comment', content=u'cubicweb cubicweb', comments=c1)
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    91
            c3 = req.create_entity('Comment', content=u'cubicweb cubicweb cubicweb', comments=c1)
1e73a466aa69 [fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    92
            self.commit()
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6206
diff changeset
    93
            self.assertEqual(req.execute('Any X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows,
9499
872d16c04c79 [test] make unittest_postgres pass
Julien Cristau <julien.cristau@logilab.fr>
parents: 8694
diff changeset
    94
                              [[c1.eid,], [c3.eid,], [c2.eid,]])
6436
275e9f402ccc [test] missing main
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    95
6780
92e4c07f86c0 [server/test] raise SkipTest from setUpModule instead of setUp( unittest2 behaviour) + kill some deprecation warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6436
diff changeset
    96
7166
dde161937d3e [time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6818
diff changeset
    97
    def test_tz_datetime(self):
dde161937d3e [time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6818
diff changeset
    98
        self.execute("INSERT Personne X: X nom 'bob', X tzdatenaiss %(date)s",
dde161937d3e [time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6818
diff changeset
    99
                     {'date': datetime(1977, 6, 7, 2, 0, tzinfo=FixedOffset(1))})
dde161937d3e [time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6818
diff changeset
   100
        datenaiss = self.execute("Any XD WHERE X nom 'bob', X tzdatenaiss XD")[0][0]
7211
cacff15f847d [timezone] ensure tzinfo is None
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7166
diff changeset
   101
        self.assertEqual(datenaiss.tzinfo, None)
7166
dde161937d3e [time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6818
diff changeset
   102
        self.assertEqual(datenaiss.utctimetuple()[:5], (1977, 6, 7, 1, 0))
7228
9d04e12d2d39 [tz support] more tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7211
diff changeset
   103
        self.commit()
9d04e12d2d39 [tz support] more tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7211
diff changeset
   104
        self.execute("INSERT Personne X: X nom 'boby', X tzdatenaiss %(date)s",
9d04e12d2d39 [tz support] more tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7211
diff changeset
   105
                     {'date': datetime(1977, 6, 7, 2, 0)})
9d04e12d2d39 [tz support] more tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7211
diff changeset
   106
        datenaiss = self.execute("Any XD WHERE X nom 'boby', X tzdatenaiss XD")[0][0]
9d04e12d2d39 [tz support] more tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7211
diff changeset
   107
        self.assertEqual(datenaiss.tzinfo, None)
9d04e12d2d39 [tz support] more tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7211
diff changeset
   108
        self.assertEqual(datenaiss.utctimetuple()[:5], (1977, 6, 7, 2, 0))
7166
dde161937d3e [time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6818
diff changeset
   109
6436
275e9f402ccc [test] missing main
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
   110
if __name__ == '__main__':
275e9f402ccc [test] missing main
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
   111
    from logilab.common.testlib import unittest_main
275e9f402ccc [test] missing main
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
   112
    unittest_main()