]> git.decadent.org.uk Git - dak.git/commitdiff
Really fix the DebVersion type in dbconn.py.
authorTorsten Werner <twerner@debian.org>
Fri, 14 Jan 2011 18:46:42 +0000 (19:46 +0100)
committerTorsten Werner <twerner@debian.org>
Fri, 14 Jan 2011 19:30:02 +0000 (20:30 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py
tests/dbtest_debversion.py

index bae2bb355c3cc24869d0c166f027adba4955de43..cc7f6fe35287bbdb06b52719c5ba5f2cb22f878f 100755 (executable)
@@ -78,7 +78,7 @@ class DebVersion(UserDefinedType):
     def bind_processor(self, dialect):
         return None
 
-    def result_processor(self, dialect):
+    def result_processor(self, dialect, coltype):
         return None
 
 sa_major_version = sqlalchemy.__version__[0:3]
index 548a2e8ea5c97c626aca4f999dab16599a17fe90..86dd3d28635f55de110eb0f438b5472c82e2298f 100755 (executable)
@@ -16,6 +16,13 @@ class Version(object):
         return "<Version('%s')>" % self.version
 
 class DebVersionTestCase(DBDakTestCase):
+    """
+    The DebVersionTestCase tests both comparison (<=, ==, >, !=), the in_()
+    method and aggregate functions (min, max) for the DebVersion type. To
+    simplify the test it creates a separate table 'version' which is not used
+    by dak itself.
+    """
+
     def setUp(self):
         super(DebVersionTestCase, self).setUp()
         self.version_table = Table('version', self.metadata, \
@@ -32,12 +39,15 @@ class DebVersionTestCase(DBDakTestCase):
         self.session.add(v)
         v = Version('1.0')
         self.session.add(v)
-        #self.session.commit()
         q = self.session.query(Version)
         self.assertEqual(3, q.count())
+        self.assertEqual(2, q.filter(Version.version <= '0.5').count())
+        self.assertEqual(1, q.filter(Version.version == '0.5').count())
         self.assertEqual(2, q.filter(Version.version > '0.5~').count())
         self.assertEqual(1, q.filter(Version.version > '0.5').count())
         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))