]> err.no Git - dak/commitdiff
Test and refactor get_suites_source_in().
authorTorsten Werner <twerner@debian.org>
Sat, 22 Jan 2011 10:48:19 +0000 (11:48 +0100)
committerTorsten Werner <twerner@debian.org>
Sat, 22 Jan 2011 10:48:19 +0000 (11:48 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py
tests/dbtest_packages.py

index 06960bfdcb696abd7ab36b4194c115e44c408735..6f598bb5dd5597c061395bbceff55a6a4c8a6334 100755 (executable)
@@ -2168,7 +2168,7 @@ def get_suites_source_in(source, session=None):
     @return: list of Suite objects for the given source
     """
 
-    return session.query(Suite).join(SrcAssociation).join(DBSource).filter_by(source=source).all()
+    return session.query(Suite).filter(Suite.sources.any(source=source)).all()
 
 __all__.append('get_suites_source_in')
 
index 9af916fef9c132d85c355347ca1918047a2bcf6e..9ac4ef4ccec6f4cf5f854ed8996398d2dbb25eea 100755 (executable)
@@ -4,7 +4,8 @@ from db_test import DBDakTestCase
 
 from daklib.dbconn import Architecture, Suite, get_suite_architectures, \
     get_architecture_suites, Maintainer, DBSource, Location, PoolFile, \
-    check_poolfile, get_poolfile_like_name, get_source_in_suite
+    check_poolfile, get_poolfile_like_name, get_source_in_suite, \
+    get_suites_source_in
 
 from sqlalchemy.orm.exc import MultipleResultsFound
 import unittest
@@ -266,6 +267,12 @@ class PackageTestCase(DBDakTestCase):
             get_source_in_suite('hello', 'squeeze', self.session))
         self.assertEqual(self.source['sl'], \
             get_source_in_suite('sl', 'sid', self.session))
+        # test get_suites_source_in()
+        self.assertEqual([self.suite['sid']], \
+            get_suites_source_in('hello', self.session))
+        self.assertEqual(2, len(get_suites_source_in('sl', self.session)))
+        self.assertTrue(self.suite['squeeze'] in \
+            get_suites_source_in('sl', self.session))
 
 
 if __name__ == '__main__':