equal
deleted
inserted
replaced
4 import os |
4 import os |
5 import sys |
5 import sys |
6 import threading |
6 import threading |
7 import time |
7 import time |
8 from copy import deepcopy |
8 from copy import deepcopy |
9 |
9 from datetime import datetime |
10 from mx.DateTime import DateTimeType, now |
10 |
11 from logilab.common.testlib import TestCase, unittest_main |
11 from logilab.common.testlib import TestCase, unittest_main |
12 from cubicweb.devtools.apptest import RepositoryBasedTC |
12 from cubicweb.devtools.apptest import RepositoryBasedTC |
13 from cubicweb.devtools.repotest import tuplify |
13 from cubicweb.devtools.repotest import tuplify |
14 |
14 |
15 from yams.constraints import UniqueConstraint |
15 from yams.constraints import UniqueConstraint |
331 entity.complete = lambda x: None |
331 entity.complete = lambda x: None |
332 self.repo.add_info(self.session, entity, self.repo.sources_by_uri['system']) |
332 self.repo.add_info(self.session, entity, self.repo.sources_by_uri['system']) |
333 cursor = self.session.pool['system'] |
333 cursor = self.session.pool['system'] |
334 cursor.execute('SELECT * FROM entities WHERE eid = -1') |
334 cursor.execute('SELECT * FROM entities WHERE eid = -1') |
335 data = cursor.fetchall() |
335 data = cursor.fetchall() |
336 self.assertIsInstance(data[0][3], DateTimeType) |
336 self.assertIsInstance(data[0][3], datetime) |
337 data[0] = list(data[0]) |
337 data[0] = list(data[0]) |
338 data[0][3] = None |
338 data[0][3] = None |
339 self.assertEquals(tuplify(data), [(-1, 'Personne', 'system', None, None)]) |
339 self.assertEquals(tuplify(data), [(-1, 'Personne', 'system', None, None)]) |
340 self.repo.delete_info(self.session, -1) |
340 self.repo.delete_info(self.session, -1) |
341 #self.repo.commit() |
341 #self.repo.commit() |
348 |
348 |
349 def test_reindex_and_modified_since(self): |
349 def test_reindex_and_modified_since(self): |
350 cursor = self.session.pool['system'] |
350 cursor = self.session.pool['system'] |
351 eidp = self.execute('INSERT Personne X: X nom "toto", X prenom "tutu"')[0][0] |
351 eidp = self.execute('INSERT Personne X: X nom "toto", X prenom "tutu"')[0][0] |
352 self.commit() |
352 self.commit() |
353 ts = now() |
353 ts = datetime.now() |
354 self.assertEquals(len(self.execute('Personne X WHERE X has_text "tutu"')), 1) |
354 self.assertEquals(len(self.execute('Personne X WHERE X has_text "tutu"')), 1) |
355 cursor.execute('SELECT mtime, eid FROM entities WHERE eid = %s' % eidp) |
355 cursor.execute('SELECT mtime, eid FROM entities WHERE eid = %s' % eidp) |
356 omtime = cursor.fetchone()[0] |
356 omtime = cursor.fetchone()[0] |
357 # our sqlite datetime adapter is ignore seconds fraction, so we have to |
357 # our sqlite datetime adapter is ignore seconds fraction, so we have to |
358 # ensure update is done the next seconds |
358 # ensure update is done the next seconds |