]> git.decadent.org.uk Git - dak.git/blobdiff - tests/db_test.py
Improve test_maintainers().
[dak.git] / tests / db_test.py
index 4f01f6d5d1583a89128a4b12c1fd41c9546fd88e..fc9ce893d61d4c25aef3f1adc269cb6c21c7dc43 100644 (file)
@@ -3,7 +3,7 @@ from base_test import DakTestCase, fixture
 from daklib.config import Config
 from daklib.dbconn import DBConn
 
-from sqlalchemy import create_engine, __version__
+from sqlalchemy import create_engine, func, __version__
 from sqlalchemy.exc import SADeprecationWarning
 from sqlalchemy.schema import DDL
 
@@ -72,6 +72,15 @@ class DBDakTestCase(DakTestCase):
             self.initialize()
         self.session = DBConn().session()
 
+    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 classes_to_clean(self):
         """
         The function classes_to_clean() returns a list of classes. All objects