launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #10850
[Merge] lp:~cjwatson/launchpad/queue-filter-source into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/queue-filter-source into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #33700 in Launchpad itself: "could queue filters match source as well as binaries?"
https://bugs.launchpad.net/launchpad/+bug/33700
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/queue-filter-source/+merge/119225
== Summary ==
Bug 33700: binary package uploads can only be filtered by binary package name, not source package name. This causes us to have to make some rather odd and imprecise queries in places.
== Proposed fix ==
Join through to PackageUploadBuild.build.source_package_release.
== Implementation details ==
I did a bit of test refactoring to reduce code size.
== Tests ==
bin/test -vvct test_packageupload
== Demo and Q/A ==
Using queue from lp:ubuntu-archive-tools, these two queries should produce the same list of uploads:
queue -l qastaging -s oneiric-updates -Q done info fglrx-installer-updates
queue -l qastaging -s oneiric-updates -Q done info fglrx
Without this fix, the first only shows a source upload, not the two corresponding binary uploads.
--
https://code.launchpad.net/~cjwatson/launchpad/queue-filter-source/+merge/119225
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/queue-filter-source into lp:launchpad.
=== modified file 'lib/lp/soyuz/model/queue.py'
--- lib/lp/soyuz/model/queue.py 2012-08-06 09:29:34 +0000
+++ lib/lp/soyuz/model/queue.py 2012-08-11 02:26:22 +0000
@@ -1738,6 +1738,7 @@
version=None, exact_match=False):
"""See `IPackageUploadSet`."""
# Avoid circular imports.
+ from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
from lp.soyuz.model.packagecopyjob import PackageCopyJob
from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
@@ -1784,16 +1785,22 @@
source_join = LeftJoin(
PackageUploadSource,
PackageUploadSource.packageuploadID == PackageUpload.id)
+ build_join = LeftJoin(
+ PackageUploadBuild,
+ PackageUploadBuild.packageuploadID == PackageUpload.id)
+ bpb_join = LeftJoin(
+ BinaryPackageBuild,
+ BinaryPackageBuild.id == PackageUploadBuild.buildID)
spr_join = LeftJoin(
SourcePackageRelease,
- SourcePackageRelease.id ==
- PackageUploadSource.sourcepackagereleaseID)
+ Or(
+ SourcePackageRelease.id ==
+ PackageUploadSource.sourcepackagereleaseID,
+ SourcePackageRelease.id ==
+ BinaryPackageBuild.source_package_release_id))
bpr_join = LeftJoin(
BinaryPackageRelease,
BinaryPackageRelease.buildID == PackageUploadBuild.buildID)
- build_join = LeftJoin(
- PackageUploadBuild,
- PackageUploadBuild.packageuploadID == PackageUpload.id)
if name is not None and name != '':
spn_join = LeftJoin(
@@ -1815,9 +1822,10 @@
joins += [
package_copy_job_join,
source_join,
+ build_join,
+ bpb_join,
spr_join,
spn_join,
- build_join,
bpr_join,
bpn_join,
custom_join,
@@ -1834,8 +1842,9 @@
if version is not None and version != '':
joins += [
source_join,
+ build_join,
+ bpb_join,
spr_join,
- build_join,
bpr_join,
]
=== modified file 'lib/lp/soyuz/tests/test_packageupload.py'
--- lib/lp/soyuz/tests/test_packageupload.py 2012-07-24 06:39:54 +0000
+++ lib/lp/soyuz/tests/test_packageupload.py 2012-08-11 02:26:22 +0000
@@ -138,11 +138,8 @@
'foocomm_1.0-2_binary/foocomm_1.0-2_i386.changes')
changesfile_content = ''
- handle = open(changesfile_path, 'r')
- try:
+ with open(changesfile_path, 'r') as handle:
changesfile_content = handle.read()
- finally:
- handle.close()
source = self.test_publisher.getPubSource(
sourcename='foocomm', archive=ppa, version='1.0-2',
@@ -194,8 +191,7 @@
self.assertEquals(pocket, pub_record.pocket)
self.assertEquals(component, pub_record.component)
for pub_file in pub_record.files:
- self.assertEqual(
- restricted, pub_file.libraryfilealias.restricted)
+ self.assertEqual(restricted, pub_file.libraryfilealias.restricted)
def removeRepository(self, distro):
"""Remove the testing repository root if it exists."""
@@ -227,8 +223,7 @@
# Release ubuntutest/breezy-autotest, so delayed-copies to
# SECURITY pocket can be accepted.
- self.test_publisher.breezy_autotest.status = (
- SeriesStatus.CURRENT)
+ self.test_publisher.breezy_autotest.status = SeriesStatus.CURRENT
# Create an ancestry publication in 'multiverse'.
ancestry_source = self.test_publisher.getPubSource(
@@ -245,8 +240,7 @@
# Accept and publish the delayed-copy.
delayed_copy.acceptFromCopy()
- self.assertEquals(
- PackageUploadStatus.ACCEPTED, delayed_copy.status)
+ self.assertEquals(PackageUploadStatus.ACCEPTED, delayed_copy.status)
# Make sure no announcement email was sent at this point.
self.assertEquals(len(stub.test_emails), 0)
@@ -263,8 +257,7 @@
pub_records = delayed_copy.realiseUpload(logger=logger)
finally:
os.umask(old_umask)
- self.assertEquals(
- PackageUploadStatus.DONE, delayed_copy.status)
+ self.assertEquals(PackageUploadStatus.DONE, delayed_copy.status)
self.layer.txn.commit()
@@ -332,8 +325,7 @@
# Create the default delayed-copy context.
delayed_copy = self.createDelayedCopy(source_only=True)
- self.test_publisher.breezy_autotest.status = (
- SeriesStatus.CURRENT)
+ self.test_publisher.breezy_autotest.status = SeriesStatus.CURRENT
self.layer.txn.commit()
# Accept and publish the delayed-copy.
@@ -346,8 +338,7 @@
self.assertEquals(1, len(pub_records))
[pub_record] = pub_records
[build] = pub_record.getBuilds()
- self.assertEquals(
- BuildStatus.NEEDSBUILD, build.status)
+ self.assertEquals(BuildStatus.NEEDSBUILD, build.status)
def test_realiseUpload_for_overridden_component_archive(self):
# If the component of an upload is overridden to 'Partner' for
@@ -373,8 +364,7 @@
main_component = getUtility(IComponentSet)['main']
package_upload.overrideSource(
partner_component, None, [partner_component, main_component])
- self.assertEqual(
- "partner", main_upload_release.upload_archive.name)
+ self.assertEqual("partner", main_upload_release.upload_archive.name)
# Now realise the upload and verify that the publishing is for
# the partner archive.
@@ -447,8 +437,7 @@
def test_package_copy_job_property(self):
# Test that we can set and get package_copy_job.
pu, pcj = self.makeUploadWithPackageCopyJob()
- self.assertEqual(
- removeSecurityProxy(pcj).context, pu.package_copy_job)
+ self.assertEqual(removeSecurityProxy(pcj).context, pu.package_copy_job)
def test_getByPackageCopyJobIDs(self):
# getByPackageCopyJobIDs retrieves the right PackageCopyJob.
@@ -575,77 +564,66 @@
upload_set = getUtility(IPackageUploadSet)
self.assertThat(upload_set, Provides(IPackageUploadSet))
+ def assertUploadsEqual(self, expected, *args, **kwargs):
+ upload_set = getUtility(IPackageUploadSet)
+ self.assertContentEqual(expected, upload_set.getAll(*args, **kwargs))
+
def test_getAll_returns_source_upload(self):
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeSourcePackageUpload(distroseries)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual([upload], upload_set.getAll(distroseries))
+ self.assertUploadsEqual([upload], distroseries)
def test_getAll_returns_build_upload(self):
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeBuildPackageUpload(distroseries)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual([upload], upload_set.getAll(distroseries))
+ self.assertUploadsEqual([upload], distroseries)
def test_getAll_returns_custom_upload(self):
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeCustomPackageUpload(distroseries)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual([upload], upload_set.getAll(distroseries))
+ self.assertUploadsEqual([upload], distroseries)
def test_getAll_returns_copy_job_upload(self):
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeCopyJobPackageUpload(distroseries)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual([upload], upload_set.getAll(distroseries))
+ self.assertUploadsEqual([upload], distroseries)
def test_getAll_filters_by_distroseries(self):
distroseries = self.factory.makeDistroSeries()
self.factory.makeSourcePackageUpload(distroseries)
other_series = self.factory.makeDistroSeries()
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual([], upload_set.getAll(other_series))
+ self.assertUploadsEqual([], other_series)
def test_getAll_matches_created_since_date(self):
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeSourcePackageUpload(distroseries)
yesterday = upload.date_created - timedelta(1)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload],
- upload_set.getAll(distroseries, created_since_date=yesterday))
+ self.assertUploadsEqual(
+ [upload], distroseries, created_since_date=yesterday)
def test_getAll_filters_by_created_since_date(self):
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeSourcePackageUpload(distroseries)
tomorrow = upload.date_created + timedelta(1)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, created_since_date=tomorrow))
+ self.assertUploadsEqual([], distroseries, created_since_date=tomorrow)
def test_getAll_matches_status(self):
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeSourcePackageUpload(distroseries)
status = upload.status
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload], upload_set.getAll(distroseries, status=status))
+ self.assertUploadsEqual([upload], distroseries, status=status)
def test_getAll_filters_by_status(self):
distroseries = self.factory.makeDistroSeries()
self.factory.makeSourcePackageUpload(distroseries)
status = PackageUploadStatus.DONE
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, status=status))
+ self.assertUploadsEqual([], distroseries, status=status)
def test_getAll_matches_pocket(self):
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeSourcePackageUpload(distroseries)
pocket = upload.pocket
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload], upload_set.getAll(distroseries, pocket=pocket))
+ self.assertUploadsEqual([upload], distroseries, pocket=pocket)
def test_getAll_filters_by_pocket(self):
def find_different_pocket_than(pocket):
@@ -656,19 +634,15 @@
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeSourcePackageUpload(distroseries)
pocket = find_different_pocket_than(upload.pocket)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, pocket=pocket))
+ self.assertUploadsEqual([], distroseries, pocket=pocket)
def test_getAll_matches_custom_type(self):
distroseries = self.factory.makeDistroSeries()
custom_type = PackageUploadCustomFormat.DDTP_TARBALL
upload = self.factory.makeCustomPackageUpload(
distroseries, custom_type=custom_type)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload],
- upload_set.getAll(distroseries, custom_type=custom_type))
+ self.assertUploadsEqual(
+ [upload], distroseries, custom_type=custom_type)
def test_getAll_filters_by_custom_type(self):
distroseries = self.factory.makeDistroSeries()
@@ -676,78 +650,68 @@
other_type = PackageUploadCustomFormat.ROSETTA_TRANSLATIONS
self.factory.makeCustomPackageUpload(
distroseries, custom_type=one_type)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, custom_type=other_type))
+ self.assertUploadsEqual([], distroseries, custom_type=other_type)
def test_getAll_matches_source_upload_by_package_name(self):
distroseries = self.factory.makeDistroSeries()
spn = self.factory.makeSourcePackageName()
upload = self.factory.makeSourcePackageUpload(
distroseries, sourcepackagename=spn)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload], upload_set.getAll(distroseries, name=spn.name))
+ self.assertUploadsEqual([upload], distroseries, name=spn.name)
def test_getAll_filters_source_upload_by_package_name(self):
distroseries = self.factory.makeDistroSeries()
self.factory.makeSourcePackageUpload(distroseries)
other_name = self.factory.makeSourcePackageName().name
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, name=other_name))
+ self.assertUploadsEqual([], distroseries, name=other_name)
def test_getAll_matches_build_upload_by_package_name(self):
distroseries = self.factory.makeDistroSeries()
bpn = self.factory.makeBinaryPackageName()
upload = self.factory.makeBuildPackageUpload(
distroseries, binarypackagename=bpn)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload], upload_set.getAll(distroseries, name=bpn.name))
+ self.assertUploadsEqual([upload], distroseries, name=bpn.name)
def test_getAll_filters_build_upload_by_package_name(self):
distroseries = self.factory.makeDistroSeries()
self.factory.makeBuildPackageUpload(distroseries)
other_name = self.factory.makeBinaryPackageName().name
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, name=other_name))
+ self.assertUploadsEqual([], distroseries, name=other_name)
+
+ def test_getAll_matches_build_upload_by_source_name(self):
+ distroseries = self.factory.makeDistroSeries()
+ bpn = self.factory.makeBinaryPackageName()
+ upload = self.factory.makeBuildPackageUpload(distroseries)
+ source_name = upload.builds[0].build.source_package_release.name
+ self.assertNotEqual(bpn.name, source_name)
+ self.assertUploadsEqual([upload], distroseries, name=source_name)
def test_getAll_matches_custom_upload_by_file_name(self):
distroseries = self.factory.makeDistroSeries()
filename = self.factory.getUniqueUnicode()
upload = self.factory.makeCustomPackageUpload(
distroseries, filename=filename)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload], upload_set.getAll(distroseries, name=filename))
+ self.assertUploadsEqual([upload], distroseries, name=filename)
def test_getAll_filters_custom_upload_by_file_name(self):
distroseries = self.factory.makeDistroSeries()
filename = self.factory.getUniqueString()
self.factory.makeCustomPackageUpload(distroseries, filename=filename)
other_name = self.factory.getUniqueUnicode()
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, name=other_name))
+ self.assertUploadsEqual([], distroseries, name=other_name)
def test_getAll_matches_copy_job_upload_by_package_name(self):
distroseries = self.factory.makeDistroSeries()
spn = self.factory.makeSourcePackageName()
upload = self.factory.makeCopyJobPackageUpload(
distroseries, sourcepackagename=spn)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload], upload_set.getAll(distroseries, name=spn.name))
+ self.assertUploadsEqual([upload], distroseries, name=spn.name)
def test_getAll_filters_copy_job_upload_by_package_name(self):
distroseries = self.factory.makeDistroSeries()
self.factory.makeCopyJobPackageUpload(distroseries)
other_name = self.factory.makeSourcePackageName().name
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, name=other_name))
+ self.assertUploadsEqual([], distroseries, name=other_name)
def test_getAll_without_exact_match_matches_substring_of_name(self):
distroseries = self.factory.makeDistroSeries()
@@ -755,19 +719,15 @@
upload = self.factory.makeSourcePackageUpload(
distroseries, sourcepackagename=spn)
partial_name = spn.name[:-1]
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload], upload_set.getAll(distroseries, name=partial_name))
+ self.assertUploadsEqual([upload], distroseries, name=partial_name)
def test_getAll_with_exact_match_matches_exact_name(self):
distroseries = self.factory.makeDistroSeries()
spn = self.factory.makeSourcePackageName()
upload = self.factory.makeSourcePackageUpload(
distroseries, sourcepackagename=spn)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload],
- upload_set.getAll(distroseries, name=spn.name, exact_match=True))
+ self.assertUploadsEqual(
+ [upload], distroseries, name=spn.name, exact_match=True)
def test_getAll_with_exact_match_does_not_match_substring_of_name(self):
distroseries = self.factory.makeDistroSeries()
@@ -775,63 +735,46 @@
self.factory.makeSourcePackageUpload(
distroseries, sourcepackagename=spn)
partial_name = spn.name[:-1]
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [],
- upload_set.getAll(
- distroseries, name=partial_name, exact_match=True))
+ self.assertUploadsEqual(
+ [], distroseries, name=partial_name, exact_match=True)
def test_getAll_without_exact_match_escapes_name(self):
distroseries = self.factory.makeDistroSeries()
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, name=u"'"))
+ self.assertUploadsEqual([], distroseries, name=u"'")
def test_getAll_with_exact_match_escapes_name(self):
distroseries = self.factory.makeDistroSeries()
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, name=u"'", exact_match=True))
+ self.assertUploadsEqual([], distroseries, name=u"'", exact_match=True)
def test_getAll_matches_source_upload_by_version(self):
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeSourcePackageUpload(distroseries)
version = upload.displayversion
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload], upload_set.getAll(distroseries, version=version))
+ self.assertUploadsEqual([upload], distroseries, version=version)
def test_getAll_filters_source_upload_by_version(self):
distroseries = self.factory.makeDistroSeries()
self.factory.makeSourcePackageUpload(distroseries)
other_version = self.factory.getUniqueUnicode()
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, version=other_version))
+ self.assertUploadsEqual([], distroseries, version=other_version)
def test_getAll_matches_build_upload_by_version(self):
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeBuildPackageUpload(distroseries)
version = upload.displayversion
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload], upload_set.getAll(distroseries, version=version))
+ self.assertUploadsEqual([upload], distroseries, version=version)
def test_getAll_filters_build_upload_by_version(self):
distroseries = self.factory.makeDistroSeries()
other_version = self.factory.getUniqueUnicode()
self.factory.makeBuildPackageUpload(distroseries)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, version=other_version))
+ self.assertUploadsEqual([], distroseries, version=other_version)
def test_getAll_version_filter_ignores_custom_uploads(self):
distroseries = self.factory.makeDistroSeries()
other_version = self.factory.getUniqueUnicode()
self.factory.makeCustomPackageUpload(distroseries)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, version=other_version))
+ self.assertUploadsEqual([], distroseries, version=other_version)
def test_getAll_version_filter_ignores_copy_job_uploads(self):
# Version match for package copy jobs is not implemented at the
@@ -839,48 +782,36 @@
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeCopyJobPackageUpload(distroseries)
version = upload.package_copy_job.package_version
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [], upload_set.getAll(distroseries, version=version))
+ self.assertUploadsEqual([], distroseries, version=version)
def test_getAll_without_exact_match_matches_substring_of_version(self):
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeSourcePackageUpload(distroseries)
version = upload.displayversion[1:-1]
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload], upload_set.getAll(distroseries, version=version))
+ self.assertUploadsEqual([upload], distroseries, version=version)
def test_getAll_with_exact_match_matches_exact_version(self):
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeSourcePackageUpload(distroseries)
version = upload.displayversion
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [upload],
- upload_set.getAll(
- distroseries, version=version, exact_match=True))
+ self.assertUploadsEqual(
+ [upload], distroseries, version=version, exact_match=True)
def test_getAll_w_exact_match_does_not_match_substring_of_version(self):
distroseries = self.factory.makeDistroSeries()
upload = self.factory.makeSourcePackageUpload(distroseries)
version = upload.displayversion[1:-1]
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
- [],
- upload_set.getAll(
- distroseries, version=version, exact_match=True))
+ self.assertUploadsEqual(
+ [], distroseries, version=version, exact_match=True)
def test_getAll_can_combine_version_and_name(self):
distroseries = self.factory.makeDistroSeries()
spn = self.factory.makeSourcePackageName()
upload = self.factory.makeSourcePackageUpload(
distroseries, sourcepackagename=spn)
- upload_set = getUtility(IPackageUploadSet)
- self.assertContentEqual(
+ self.assertUploadsEqual(
[upload],
- upload_set.getAll(
- distroseries, name=spn.name, version=upload.displayversion))
+ distroseries, name=spn.name, version=upload.displayversion)
def test_getAll_orders_in_reverse_historical_order(self):
# The results from getAll are returned in order of creation,
Follow ups