From: Torsten Werner Date: Sat, 22 Jan 2011 10:48:19 +0000 (+0100) Subject: Test and refactor get_suites_source_in(). X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=99aed3cc2eb9db877c71b9a6e039cc38241e45f5;p=dak.git Test and refactor get_suites_source_in(). Signed-off-by: Torsten Werner --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 06960bfd..6f598bb5 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -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') diff --git a/tests/dbtest_packages.py b/tests/dbtest_packages.py index 9af916fe..9ac4ef4c 100755 --- a/tests/dbtest_packages.py +++ b/tests/dbtest_packages.py @@ -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__':