Merge lp:~stevenk/launchpad/deny-ddeb-deletion into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: Steve Kowalik
Approved revision: no longer in the source branch.
Merged at revision: 16618
Proposed branch: lp:~stevenk/launchpad/deny-ddeb-deletion
Merge into: lp:launchpad
Diff against target: 76 lines (+30/-2)
3 files modified
lib/lp/soyuz/model/publishing.py (+12/-0)
lib/lp/soyuz/tests/test_publishing.py (+16/-0)
lib/lp/testing/__init__.py (+2/-2)
To merge this branch: bzr merge lp:~stevenk/launchpad/deny-ddeb-deletion
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+163633@code.launchpad.net

Commit message

Reject overridding or deletion of a debug publication directly.

Description of the change

Reject overridding or deletion of a debug publication directly -- they should be performed on the publication, which then filters down. Also teach assertRaisesWithContent about kwargs.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

16:26:25 < wgrant> StevenK: Should that be OverrideError rather than AssertionError? Otherwise +1

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/soyuz/model/publishing.py'
2--- lib/lp/soyuz/model/publishing.py 2013-05-08 06:18:50 +0000
3+++ lib/lp/soyuz/model/publishing.py 2013-05-14 06:33:24 +0000
4@@ -1159,6 +1159,12 @@
5 "component, section, priority and/or "
6 "phased_update_percentage.")
7
8+ bpr = self.binarypackagerelease
9+ if bpr.binpackageformat == BinaryPackageFormat.DDEB:
10+ raise OverrideError(
11+ "Cannot override ddeb publications directly; override "
12+ "the corresponding deb instead.")
13+
14 # Check there is a change to make
15 if new_component is None:
16 new_component = self.component
17@@ -1300,6 +1306,12 @@
18 "Cannot delete publications from suite '%s'" %
19 self.distroseries.getSuite(self.pocket))
20
21+ bpr = self.binarypackagerelease
22+ if bpr.binpackageformat == BinaryPackageFormat.DDEB:
23+ raise DeletionError(
24+ "Cannot delete ddeb publications directly; delete the "
25+ "corresponding deb instead.")
26+
27 self.setDeleted(removed_by, removal_comment)
28
29 def binaryFileUrls(self, include_meta=False):
30
31=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
32--- lib/lp/soyuz/tests/test_publishing.py 2013-05-08 06:08:37 +0000
33+++ lib/lp/soyuz/tests/test_publishing.py 2013-05-14 06:33:24 +0000
34@@ -1056,6 +1056,22 @@
35 [new_bpph])
36 self.assertEqual(new_debug_bpph.section, new_section)
37
38+ def test_requestDeletion_forbids_debug_package(self):
39+ bpph, debug_bpph = self.factory.makeBinaryPackagePublishingHistory(
40+ pocket=PackagePublishingPocket.RELEASE, with_debug=True)
41+ self.assertRaisesWithContent(
42+ DeletionError, "Cannot delete ddeb publications directly; delete "
43+ "the corresponding deb instead.",
44+ debug_bpph.requestDeletion, self.factory.makePerson())
45+
46+ def test_changeOverride_forbids_debug_package(self):
47+ bpph, debug_bpph = self.factory.makeBinaryPackagePublishingHistory(
48+ pocket=PackagePublishingPocket.RELEASE, with_debug=True)
49+ self.assertRaisesWithContent(
50+ OverrideError, "Cannot override ddeb publications directly; "
51+ "override the corresponding deb instead.",
52+ debug_bpph.changeOverride, new_phased_update_percentage=20)
53+
54
55 class TestSourceDomination(TestNativePublishingBase):
56 """Test SourcePackagePublishingHistory.supersede() operates correctly."""
57
58=== modified file 'lib/lp/testing/__init__.py'
59--- lib/lp/testing/__init__.py 2012-12-26 01:34:53 +0000
60+++ lib/lp/testing/__init__.py 2013-05-14 06:33:24 +0000
61@@ -573,13 +573,13 @@
62 self.assertThat(iter1, MatchesSetwise(*(map(Equals, iter2))))
63
64 def assertRaisesWithContent(self, exception, exception_content,
65- func, *args):
66+ func, *args, **kwargs):
67 """Check if the given exception is raised with given content.
68
69 If the exception isn't raised or the exception_content doesn't
70 match what was raised an AssertionError is raised.
71 """
72- err = self.assertRaises(exception, func, *args)
73+ err = self.assertRaises(exception, func, *args, **kwargs)
74 self.assertEqual(exception_content, str(err))
75
76 def assertBetween(self, lower_bound, variable, upper_bound):