X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=tests%2Fdbtest_timestamps.py;h=8229e5dbdeb083ccce5ccc0121abf30a03c41d0e;hb=17c5cab4eb8d5181ec7a81267a4e2e6b43c0fc65;hp=1a53ae8665da5c9241370165bc5136c5926533a8;hpb=d95cba5badefe3dc554fbbdad729cc315aa33092;p=dak.git diff --git a/tests/dbtest_timestamps.py b/tests/dbtest_timestamps.py index 1a53ae86..8229e5db 100755 --- a/tests/dbtest_timestamps.py +++ b/tests/dbtest_timestamps.py @@ -4,7 +4,6 @@ from db_test import DBDakTestCase from daklib.dbconn import DBConn, Uid -from sqlalchemy import func import time import unittest @@ -16,20 +15,12 @@ class TimestampTestCase(DBDakTestCase): TODO: Should we check all tables? """ - def now(self): - "returns the current time at the db server" - - # we fetch a fresh session each time to avoid caching - local_session = DBConn().session() - current_time = local_session.query(func.now()).scalar() - local_session.close() - return current_time - def sleep(self): time.sleep(0.001) def test_timestamps(self): timestamp01 = self.now() + self.session.rollback() self.sleep() uid = Uid(uid = 'ftp-master@debian.org') self.session.add(uid) @@ -38,6 +29,7 @@ class TimestampTestCase(DBDakTestCase): modified01 = uid.modified self.sleep() timestamp02 = self.now() + self.session.rollback() self.assertTrue(timestamp01 < created01) self.assertTrue(timestamp01 < modified01) self.assertTrue(created01 < timestamp02) @@ -50,6 +42,7 @@ class TimestampTestCase(DBDakTestCase): self.assertEqual(created01, created02) self.assertTrue(modified01 < modified02) self.sleep() + self.session.rollback() timestamp03 = self.now() self.assertTrue(modified02 < timestamp03)