from daklib.dbconn import DBConn, Uid
-from sqlalchemy import func
import time
import unittest
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)
modified01 = uid.modified
self.sleep()
timestamp02 = self.now()
+ self.session.rollback()
self.assertTrue(timestamp01 < created01)
self.assertTrue(timestamp01 < modified01)
self.assertTrue(created01 < timestamp02)
self.assertEqual(created01, created02)
self.assertTrue(modified01 < modified02)
self.sleep()
+ self.session.rollback()
timestamp03 = self.now()
self.assertTrue(modified02 < timestamp03)