]> git.decadent.org.uk Git - dak.git/commitdiff
Improve database tests.
authorTorsten Werner <twerner@debian.org>
Fri, 14 Jan 2011 23:04:51 +0000 (00:04 +0100)
committerTorsten Werner <twerner@debian.org>
Fri, 14 Jan 2011 23:04:51 +0000 (00:04 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py
tests/dbtest_debversion.py
tests/dbtest_fingerprint.py

index d72f002c522baf0a9869b5ca6724d25dceef746e..0db4caf1be04dd28809d9bea116df1267ae04c87 100755 (executable)
@@ -1226,8 +1226,8 @@ __all__.append('add_poolfile')
 ################################################################################
 
 class Fingerprint(object):
-    def __init__(self, *args, **kwargs):
-        pass
+    def __init__(self, fingerprint = None):
+        self.fingerprint = fingerprint
 
     def __repr__(self):
         return '<Fingerprint %s>' % self.fingerprint
@@ -2676,8 +2676,9 @@ __all__.append('get_suite_src_formats')
 ################################################################################
 
 class Uid(object):
-    def __init__(self, *args, **kwargs):
-        pass
+    def __init__(self, uid = None, name = None):
+        self.uid = uid
+        self.name = name
 
     def __eq__(self, val):
         if isinstance(val, str):
index 86dd3d28635f55de110eb0f438b5472c82e2298f..ae4baf1ba6e08ae283fce4f0902681ea934d293b 100755 (executable)
@@ -48,10 +48,10 @@ class DebVersionTestCase(DBDakTestCase):
         self.assertEqual(0, q.filter(Version.version > '1.0').count())
         self.assertEqual(2, q.filter(Version.version != '1.0').count())
         self.assertEqual(2, q.filter(Version.version.in_(['0.5~', '1.0'])).count())
-        q = self.session.query(func.min(Version.version))
-        self.assertEqual('0.5~', q.one()[0])
-        q = self.session.query(func.max(Version.version))
-        self.assertEqual('1.0', q.one()[0])
+        q = self.session.query(func.min(Version.version).label('min'))
+        self.assertEqual('0.5~', q.one().min)
+        q = self.session.query(func.max(Version.version).label('max'))
+        self.assertEqual('1.0', q.one().max)
 
     def tearDown(self):
         self.session.close()
index efd994d3267dec5f1b8f9b9ad9290ccc016d8742..581795a5a987199170c8b237ec9e3db38340122c 100755 (executable)
@@ -2,23 +2,23 @@
 
 from db_test import DBDakTestCase
 
-from daklib.dbconn import Fingerprint
+from daklib.dbconn import Fingerprint, Uid
 
 import unittest
 
 class FingerprintTestCase(DBDakTestCase):
     def test_mini(self):
-        fingerprint = Fingerprint()
-        fingerprint.fingerprint = 'deadbeefdeadbeef'
+        fingerprint = Fingerprint(fingerprint = 'deadbeefdeadbeef')
         self.session.add(fingerprint)
-        self.session.commit
         query = self.session.query(Fingerprint)
         self.assertEqual(1, query.count())
         self.assertEqual('deadbeefdeadbeef', query.one().fingerprint)
-
-    def tearDown(self):
-        self.session.query(Fingerprint).delete()
-        super(FingerprintTestCase, self).tearDown()
+        fingerprint.uid = Uid(uid = 'ftp-master@debian.org', name = 'ftpteam')
+        uid = self.session.query(Uid).one()
+        self.assertEqual('ftp-master@debian.org', uid.uid)
+        self.assertEqual('ftpteam', uid.name)
+        self.assertEqual(1, len(uid.fingerprint))
+        self.assertEqual('deadbeefdeadbeef', uid.fingerprint[0].fingerprint)
 
 if __name__ == '__main__':
     unittest.main()