]> git.decadent.org.uk Git - dak.git/commitdiff
Create, test, and improve get_suite_version().
authorTorsten Werner <twerner@debian.org>
Sat, 22 Jan 2011 21:52:13 +0000 (22:52 +0100)
committerTorsten Werner <twerner@debian.org>
Sat, 22 Jan 2011 21:52:13 +0000 (22:52 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/queue.py
tests/dbtest_packages.py

index 9130c3a38ab1758382c0bbc851039cf48773ab77..08ac23fa8f96a414b9eb7f5c0e4a3f5e5eecbaab 100755 (executable)
@@ -383,6 +383,12 @@ def get_newest_source(source, session):
         order_by(desc('source.version'))
     return q.first()
 
+def get_suite_version(source, session):
+    'returns a list of tuples (suite_name, version) for source package'
+    q = session.query(Suite.suite_name, DBSource.version). \
+        join(Suite.sources).filter_by(source = source)
+    return q.all()
+
 class Upload(object):
     """
     Everything that has to do with an upload processed.
@@ -2515,10 +2521,7 @@ distribution."""
         version = self.pkg.dsc.get("version")
 
         # Ensure version is sane
-        q = session.query(SrcAssociation)
-        q = q.join(DBSource).filter(DBSource.source==source)
-
-        self.cross_suite_version_check([ (x.suite.suite_name, x.source.version) for x in q.all() ],
+        self.cross_suite_version_check(get_suite_version(source, session),
                                        filename, version, sourceful=True)
 
     ################################################################################
index 5f5b89c6a536c34dfbcb1d8ca14947d8b8227256..0f5f6e88fdd7762d12cb446c5dbecaada46338f0 100755 (executable)
@@ -7,7 +7,7 @@ from daklib.dbconn import Architecture, Suite, get_suite_architectures, \
     check_poolfile, get_poolfile_like_name, get_source_in_suite, \
     get_suites_source_in, add_dsc_to_db, source_exists
 from daklib.queue_install import package_to_suite
-from daklib.queue import get_newest_source
+from daklib.queue import get_newest_source, get_suite_version
 
 from sqlalchemy.orm.exc import MultipleResultsFound
 import unittest
@@ -369,15 +369,26 @@ class PackageTestCase(DBDakTestCase):
         self.assertTrue(package_to_suite(upload, 'lenny', self.session))
 
     def test_get_newest_source(self):
-        'test function get_newest_source'
+        'test function get_newest_source()'
 
         self.setup_sources()
-        self.session.flush()
         import daklib.queue
         daklib.queue.dm_suites = ['sid']
         self.assertEqual(self.source['hello'], get_newest_source('hello', self.session))
         self.assertEqual(None, get_newest_source('foobar', self.session))
 
+    def test_get_suite_version(self):
+        'test function get_suite_version()'
+
+        self.setup_sources()
+        result = get_suite_version('hello', self.session)
+        self.assertEqual(2, len(result))
+        self.assertTrue(('sid', '2.2-1') in result)
+        self.assertTrue(('sid', '2.2-2') in result)
+        result = get_suite_version('sl', self.session)
+        self.assertEqual(2, len(result))
+        self.assertTrue(('squeeze', '3.03-16') in result)
+        self.assertTrue(('sid', '3.03-16') in result)
 
 if __name__ == '__main__':
     unittest.main()