3 from db_test import DBDakTestCase
5 from daklib.dbconn import DBConn, Uid
7 from sqlalchemy import func
11 class TimestampTestCase(DBDakTestCase):
13 TimestampTestCase checks that the timestamps created and modified are
16 TODO: Should we check all tables?
20 "returns the current time at the db server"
22 # we fetch a fresh session each time to avoid caching
23 local_session = DBConn().session()
24 current_time = local_session.query(func.now()).scalar()
31 def test_timestamps(self):
32 timestamp01 = self.now()
34 uid = Uid(uid = 'ftp-master@debian.org')
37 created01 = uid.created
38 modified01 = uid.modified
40 timestamp02 = self.now()
41 self.assertTrue(timestamp01 < created01)
42 self.assertTrue(timestamp01 < modified01)
43 self.assertTrue(created01 < timestamp02)
44 self.assertTrue(modified01 < timestamp02)
48 created02 = uid.created
49 modified02 = uid.modified
50 self.assertEqual(created01, created02)
51 self.assertTrue(modified01 < modified02)
53 timestamp03 = self.now()
54 self.assertTrue(modified02 < timestamp03)
56 def classes_to_clean(self):
59 if __name__ == '__main__':