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
1=== modified file 'lib/lp/archiveuploader/tests/test_permission.py'
2--- lib/lp/archiveuploader/tests/test_permission.py 2010-02-02 14:01:02 +0000
3+++ lib/lp/archiveuploader/tests/test_permission.py 2010-02-08 13:51:22 +0000
4@@ -62,8 +62,6 @@
5 """Assert that 'person' can upload 'spn' to 'archive'."""
6 # For now, just check that doesn't raise an exception.
7 if distroseries is None:
8- distroseries = archive.distribution.currentseries
9- if distroseries is None:
10 distroseries = self.factory.makeDistroSeries(
11 distribution=archive.distribution)
12 pocket = PackagePublishingPocket.RELEASE
13@@ -87,8 +85,6 @@
14 :param distroseries: The upload's target distro series.
15 """
16 if distroseries is None:
17- distroseries = archive.distribution.currentseries
18- if distroseries is None:
19 distroseries = self.factory.makeDistroSeries()
20 pocket = PackagePublishingPocket.RELEASE
21 exception = check_upload_to_archive(
22
23=== modified file 'lib/lp/archiveuploader/tests/test_uploadprocessor.py'
24--- lib/lp/archiveuploader/tests/test_uploadprocessor.py 2010-01-20 15:41:25 +0000
25+++ lib/lp/archiveuploader/tests/test_uploadprocessor.py 2010-02-08 13:51:22 +0000
26@@ -26,6 +26,7 @@
27 from lp.archiveuploader.uploadprocessor import UploadProcessor
28 from canonical.config import config
29 from canonical.database.constants import UTC_NOW
30+from canonical.launchpad.webapp.interfaces import NotFoundError
31 from lp.soyuz.model.archivepermission import ArchivePermission
32 from lp.soyuz.model.binarypackagename import BinaryPackageName
33 from lp.soyuz.model.binarypackagerelease import (
34@@ -1621,6 +1622,38 @@
35 in raw_msg,
36 "Source was not rejected properly:\n%s" % raw_msg)
37
38+ def testUploadToWrongPocketIsRejected(self):
39+ # Uploads to the wrong pocket are rejected.
40+ self.setupBreezy()
41+ breezy = self.ubuntu['breezy']
42+ breezy.status = SeriesStatus.CURRENT
43+ uploadprocessor = UploadProcessor(
44+ self.options, self.layer.txn, self.log)
45+
46+ upload_dir = self.queueUpload("bar_1.0-1")
47+ self.processUpload(uploadprocessor, upload_dir)
48+ rejection_message = (
49+ uploadprocessor.last_processed_upload.rejection_message)
50+ self.assertEqual(
51+ "Not permitted to upload to the RELEASE pocket in a series in "
52+ "the 'CURRENT' state.",
53+ rejection_message)
54+
55+ contents = [
56+ "Subject: bar_1.0-1_source.changes rejected",
57+ "Not permitted to upload to the RELEASE pocket in a series "
58+ "in the 'CURRENT' state.",
59+ "If you don't understand why your files were rejected",
60+ "http://answers.launchpad.net/soyuz",
61+ "You are receiving this email because you are the "
62+ "uploader, maintainer or",
63+ "signer of the above package.",
64+ ]
65+ recipients = [
66+ 'Foo Bar <foo.bar@canonical.com>',
67+ 'Daniel Silverstone <daniel.silverstone@canonical.com>',
68+ ]
69+ self.assertEmail(contents, recipients=recipients)
70
71 def test_suite():
72 return unittest.TestLoader().loadTestsFromName(__name__)