author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Mon, 27 Feb 2012 17:02:31 +0100 | |
changeset 8298 | 2a4bc6f75e9c |
parent 8190 | 2a3c1b787688 |
child 8349 | fdb796435d7b |
permissions | -rw-r--r-- |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
1 |
# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
3 |
# |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
4 |
# This file is part of Logilab-common. |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
5 |
# |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
6 |
# Logilab-common is free software: you can redistribute it and/or modify it |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
7 |
# under the terms of the GNU Lesser General Public License as published by the |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
8 |
# Free Software Foundation, either version 2.1 of the License, or (at your |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
9 |
# option) any later version. |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
10 |
# |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
11 |
# Logilab-common is distributed in the hope that it will be useful, but WITHOUT |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
14 |
# details. |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
15 |
# |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
17 |
# with Logilab-common. If not, see <http://www.gnu.org/licenses/>. |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8139
diff
changeset
|
18 |
|
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
|
19 |
from __future__ import with_statement |
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
|
20 |
|
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 |
import socket |
7166
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6818
diff
changeset
|
22 |
from datetime import datetime |
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
|
23 |
|
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
|
24 |
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
|
25 |
|
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
|
26 |
from cubicweb.devtools import ApptestConfiguration |
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.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
|
28 |
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
|
29 |
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
|
30 |
|
7166
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6818
diff
changeset
|
31 |
AT_LOGILAB = socket.gethostname().endswith('.logilab.fr') # XXX |
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
|
32 |
|
7166
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6818
diff
changeset
|
33 |
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
|
34 |
|
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
|
35 |
class PostgresFTITC(CubicWebTC): |
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
|
36 |
@classmethod |
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
|
37 |
def setUpClass(cls): |
7166
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6818
diff
changeset
|
38 |
if not AT_LOGILAB: # XXX here until we can raise SkipTest in setUp to detect we can't connect to the db |
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
|
39 |
raise SkipTest('XXX %s: require logilab configuration' % cls.__name__) |
7228
9d04e12d2d39
[tz support] more tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7211
diff
changeset
|
40 |
cls.config = ApptestConfiguration('data', sourcefile='sources_postgres', |
9d04e12d2d39
[tz support] more tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7211
diff
changeset
|
41 |
apphome=cls.datadir) |
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
|
42 |
|
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
|
43 |
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
|
44 |
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
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
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
|
51 |
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
|
52 |
self.assertEqual(req.execute('Card X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows, |
8139
f9ebb6d1abc3
[server] use lgd.process_cursor to optimize processing of large resultsets
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7228
diff
changeset
|
53 |
[(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
|
54 |
|
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 |
|
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 |
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
|
57 |
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
|
58 |
__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
|
59 |
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
|
60 |
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
|
61 |
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
|
62 |
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
|
63 |
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
|
64 |
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
|
65 |
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
|
66 |
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
|
67 |
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
|
68 |
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
|
69 |
self.assertEqual(req.execute('Card X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows, |
8139
f9ebb6d1abc3
[server] use lgd.process_cursor to optimize processing of large resultsets
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7228
diff
changeset
|
70 |
[(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
|
71 |
|
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 |
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
|
73 |
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
|
74 |
__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
|
75 |
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
|
76 |
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
|
77 |
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
|
78 |
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
|
79 |
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
|
80 |
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
|
81 |
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
|
82 |
self.assertEqual(req.execute('Any X ORDERBY FTIRANK(X) DESC WHERE X has_text "cubicweb"').rows, |
8139
f9ebb6d1abc3
[server] use lgd.process_cursor to optimize processing of large resultsets
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7228
diff
changeset
|
83 |
[(c1.eid,), (c3.eid,), (c2.eid,)]) |
6436
275e9f402ccc
[test] missing main
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
84 |
|
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
|
85 |
|
7166
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6818
diff
changeset
|
86 |
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
|
87 |
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
|
88 |
{'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
|
89 |
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
|
90 |
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
|
91 |
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
|
92 |
self.commit() |
9d04e12d2d39
[tz support] more tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7211
diff
changeset
|
93 |
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
|
94 |
{'date': datetime(1977, 6, 7, 2, 0)}) |
9d04e12d2d39
[tz support] more tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7211
diff
changeset
|
95 |
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
|
96 |
self.assertEqual(datenaiss.tzinfo, None) |
9d04e12d2d39
[tz support] more tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7211
diff
changeset
|
97 |
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
|
98 |
|
6436
275e9f402ccc
[test] missing main
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
99 |
if __name__ == '__main__': |
275e9f402ccc
[test] missing main
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
100 |
from logilab.common.testlib import unittest_main |
275e9f402ccc
[test] missing main
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
101 |
unittest_main() |