Merge lp:~michael.nelson/launchpad/494391-ugly-upload-error-message into lp:launchpad

Proposed by Michael Nelson
Status: Merged
Approved by: Michael Nelson
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~michael.nelson/launchpad/494391-ugly-upload-error-message
Merge into: lp:launchpad
Diff against target: 72 lines (+33/-4)
2 files modified
lib/lp/archiveuploader/tests/test_permission.py (+0/-4)
lib/lp/archiveuploader/tests/test_uploadprocessor.py (+33/-0)
To merge this branch: bzr merge lp:~michael.nelson/launchpad/494391-ugly-upload-error-message
Reviewer Review Type Date Requested Status
Henning Eggers (community) code Approve
Review via email: mp+18831@code.launchpad.net

Commit message

Ensure that uploads to invalid pockets are reported correctly in the rejection email.

To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :

This fix for this branch actually landed with:

https://code.edge.launchpad.net/~michael.nelson/launchpad/create-source-recipe-build2/+merge/18535

as part of a cleanup (see lines 16-33 of the MP diff), but wasn't tested.

This branch just adds a test to ensure the exception is correctly printed in the email (as per bug 494391).

Small drive-by removing some redundant test-code and old lint.

Revision history for this message
Henning Eggers (henninge) wrote :

Thanks you for your branch.

Please find another way to word the comment on the test, as these should never state the obvious "Test that ...", "Ensure that ..." etc. Simply "Uploads to the wrong pocket are rejected." is enough. Also, I found it's customary not to use docstrings ("""....""") but comments (# ...) here.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/archiveuploader/tests/test_permission.py'
--- lib/lp/archiveuploader/tests/test_permission.py 2010-02-02 14:01:02 +0000
+++ lib/lp/archiveuploader/tests/test_permission.py 2010-02-08 13:51:22 +0000
@@ -62,8 +62,6 @@
62 """Assert that 'person' can upload 'spn' to 'archive'."""62 """Assert that 'person' can upload 'spn' to 'archive'."""
63 # For now, just check that doesn't raise an exception.63 # For now, just check that doesn't raise an exception.
64 if distroseries is None:64 if distroseries is None:
65 distroseries = archive.distribution.currentseries
66 if distroseries is None:
67 distroseries = self.factory.makeDistroSeries(65 distroseries = self.factory.makeDistroSeries(
68 distribution=archive.distribution)66 distribution=archive.distribution)
69 pocket = PackagePublishingPocket.RELEASE67 pocket = PackagePublishingPocket.RELEASE
@@ -87,8 +85,6 @@
87 :param distroseries: The upload's target distro series.85 :param distroseries: The upload's target distro series.
88 """86 """
89 if distroseries is None:87 if distroseries is None:
90 distroseries = archive.distribution.currentseries
91 if distroseries is None:
92 distroseries = self.factory.makeDistroSeries()88 distroseries = self.factory.makeDistroSeries()
93 pocket = PackagePublishingPocket.RELEASE89 pocket = PackagePublishingPocket.RELEASE
94 exception = check_upload_to_archive(90 exception = check_upload_to_archive(
9591
=== modified file 'lib/lp/archiveuploader/tests/test_uploadprocessor.py'
--- lib/lp/archiveuploader/tests/test_uploadprocessor.py 2010-01-20 15:41:25 +0000
+++ lib/lp/archiveuploader/tests/test_uploadprocessor.py 2010-02-08 13:51:22 +0000
@@ -26,6 +26,7 @@
26from lp.archiveuploader.uploadprocessor import UploadProcessor26from lp.archiveuploader.uploadprocessor import UploadProcessor
27from canonical.config import config27from canonical.config import config
28from canonical.database.constants import UTC_NOW28from canonical.database.constants import UTC_NOW
29from canonical.launchpad.webapp.interfaces import NotFoundError
29from lp.soyuz.model.archivepermission import ArchivePermission30from lp.soyuz.model.archivepermission import ArchivePermission
30from lp.soyuz.model.binarypackagename import BinaryPackageName31from lp.soyuz.model.binarypackagename import BinaryPackageName
31from lp.soyuz.model.binarypackagerelease import (32from lp.soyuz.model.binarypackagerelease import (
@@ -1621,6 +1622,38 @@
1621 in raw_msg,1622 in raw_msg,
1622 "Source was not rejected properly:\n%s" % raw_msg)1623 "Source was not rejected properly:\n%s" % raw_msg)
16231624
1625 def testUploadToWrongPocketIsRejected(self):
1626 # Uploads to the wrong pocket are rejected.
1627 self.setupBreezy()
1628 breezy = self.ubuntu['breezy']
1629 breezy.status = SeriesStatus.CURRENT
1630 uploadprocessor = UploadProcessor(
1631 self.options, self.layer.txn, self.log)
1632
1633 upload_dir = self.queueUpload("bar_1.0-1")
1634 self.processUpload(uploadprocessor, upload_dir)
1635 rejection_message = (
1636 uploadprocessor.last_processed_upload.rejection_message)
1637 self.assertEqual(
1638 "Not permitted to upload to the RELEASE pocket in a series in "
1639 "the 'CURRENT' state.",
1640 rejection_message)
1641
1642 contents = [
1643 "Subject: bar_1.0-1_source.changes rejected",
1644 "Not permitted to upload to the RELEASE pocket in a series "
1645 "in the 'CURRENT' state.",
1646 "If you don't understand why your files were rejected",
1647 "http://answers.launchpad.net/soyuz",
1648 "You are receiving this email because you are the "
1649 "uploader, maintainer or",
1650 "signer of the above package.",
1651 ]
1652 recipients = [
1653 'Foo Bar <foo.bar@canonical.com>',
1654 'Daniel Silverstone <daniel.silverstone@canonical.com>',
1655 ]
1656 self.assertEmail(contents, recipients=recipients)
16241657
1625def test_suite():1658def test_suite():
1626 return unittest.TestLoader().loadTestsFromName(__name__)1659 return unittest.TestLoader().loadTestsFromName(__name__)