X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=tests%2Fdb_test.py;h=dfd9c5386401ec5e7cd475a29d760d1d47dae39a;hb=3d4f5a474e5550e42c88f30bdc5fd094984dfcc1;hp=f91c15a82b783a7963a1ad51023b00b7eb767be2;hpb=1c4e1b1a2a3be107a6111b65d0d226ed80e91d76;p=dak.git diff --git a/tests/db_test.py b/tests/db_test.py index f91c15a8..dfd9c538 100644 --- a/tests/db_test.py +++ b/tests/db_test.py @@ -171,6 +171,7 @@ class DBDakTestCase(DakTestCase): if 'source' in self.__dict__: return + install_date = self.now() self.setup_maintainers() self.setup_suites() self.setup_poolfiles() @@ -178,22 +179,22 @@ class DBDakTestCase(DakTestCase): self.source['hello_2.2-2'] = DBSource(source = 'hello', version = '2.2-2', \ maintainer = self.maintainer['maintainer'], \ changedby = self.maintainer['uploader'], \ - poolfile = self.file['hello_2.2-2.dsc'], install_date = self.now()) + poolfile = self.file['hello_2.2-2.dsc'], install_date = install_date) self.source['hello_2.2-2'].suites.append(self.suite['sid']) self.source['hello_2.2-1'] = DBSource(source = 'hello', version = '2.2-1', \ maintainer = self.maintainer['maintainer'], \ changedby = self.maintainer['uploader'], \ - poolfile = self.file['hello_2.2-1.dsc'], install_date = self.now()) + poolfile = self.file['hello_2.2-1.dsc'], install_date = install_date) self.source['hello_2.2-1'].suites.append(self.suite['sid']) self.source['gnome-hello_3.0-1'] = DBSource(source = 'gnome-hello', \ version = '3.0-1', maintainer = self.maintainer['maintainer'], \ changedby = self.maintainer['uploader'], \ - poolfile = self.file['gnome-hello_3.0-1.dsc'], install_date = self.now()) + poolfile = self.file['gnome-hello_3.0-1.dsc'], install_date = install_date) self.source['gnome-hello_3.0-1'].suites.append(self.suite['sid']) self.source['sl_3.03-16'] = DBSource(source = 'sl', version = '3.03-16', \ maintainer = self.maintainer['maintainer'], \ changedby = self.maintainer['uploader'], \ - poolfile = self.file['sl_3.03-16.dsc'], install_date = self.now()) + poolfile = self.file['sl_3.03-16.dsc'], install_date = install_date) self.source['sl_3.03-16'].suites.append(self.suite['squeeze']) self.source['sl_3.03-16'].suites.append(self.suite['sid']) self.session.add_all(self.source.values()) @@ -240,13 +241,14 @@ class DBDakTestCase(DakTestCase): self.session = DBConn().session() def now(self): - "returns the current time at the db server" + """ + Returns the current time at the db server. Please note the function + returns the same value as long as it is in the same transaction. You + should self.session.rollback() (or commit) if you rely on getting a + fresh timestamp. + """ - # 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 + return self.session.query(func.now()).scalar() def classes_to_clean(self): """