join(Suite.sources).filter_by(source = source)
return q.all()
+def get_source_by_package_and_suite(package, suite_name, session):
+ '''
+ returns a DBSource query filtered by DBBinary.package and this package's
+ suite_name
+ '''
+ return session.query(DBSource). \
+ join(DBSource.binaries).filter_by(package = package). \
+ join(DBBinary.suites).filter_by(suite_name = suite_name)
+
class Upload(object):
"""
Everything that has to do with an upload processed.
## none of the packages are being taken over from other source packages
for b in self.pkg.changes["binary"].keys():
for suite in self.pkg.changes["distribution"].keys():
- q = session.query(DBSource)
- q = q.join(DBBinary).filter_by(package=b)
- q = q.join(BinAssociation).join(Suite).filter_by(suite_name=suite)
-
- for s in q.all():
+ for s in get_source_by_package_and_suite(b, suite, session):
if s.source != self.pkg.changes["source"]:
self.rejects.append("%s may not hijack %s from source package %s in suite %s" % (fpr.uid.uid, b, s, suite))
get_suites_source_in, add_dsc_to_db, source_exists, DBBinary, \
get_suites_binary_in, add_deb_to_db
from daklib.queue_install import package_to_suite
-from daklib.queue import get_newest_source, get_suite_version
+from daklib.queue import get_newest_source, get_suite_version, \
+ get_source_by_package_and_suite
from sqlalchemy.orm.exc import MultipleResultsFound
import unittest
self.assertEqual('deadbeef', poolfile.sha1sum)
self.assertEqual('deadbeef', poolfile.sha256sum)
+ def test_get_source_by_package_and_suite(self):
+ 'test get_source_by_package_and_suite()'
+
+ query = get_source_by_package_and_suite('hello', 'sid', self.session)
+ self.assertEqual(self.source['hello_2.2-1'], query.one())
+ query = get_source_by_package_and_suite('gnome-hello', 'squeeze', self.session)
+ self.assertEqual(self.source['hello_2.2-1'], query.one())
+ query = get_source_by_package_and_suite('hello', 'hamm', self.session)
+ self.assertEqual(0, query.count())
+ query = get_source_by_package_and_suite('foobar', 'squeeze', self.session)
+ self.assertEqual(0, query.count())
+
if __name__ == '__main__':
unittest.main()