]> git.decadent.org.uk Git - dak.git/commitdiff
TimestampTestCase: replace sql string by func.now.
authorTorsten Werner <twerner@debian.org>
Tue, 18 Jan 2011 04:48:44 +0000 (05:48 +0100)
committerTorsten Werner <twerner@debian.org>
Tue, 18 Jan 2011 04:52:47 +0000 (05:52 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
tests/dbtest_timestamps.py

index 98642c419624b3f25a923d0ed85c2c40a2db2775..1a53ae8665da5c9241370165bc5136c5926533a8 100755 (executable)
@@ -4,6 +4,7 @@ from db_test import DBDakTestCase
 
 from daklib.dbconn import DBConn, Uid
 
+from sqlalchemy import func
 import time
 import unittest
 
@@ -16,10 +17,13 @@ class TimestampTestCase(DBDakTestCase):
     """
 
     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()
-        query = local_session.query('now').from_statement('select now() as now')
+        current_time = local_session.query(func.now()).scalar()
         local_session.close()
-        return query.first().now
+        return current_time
 
     def sleep(self):
         time.sleep(0.001)