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
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py 2013-05-08 06:18:50 +0000
+++ lib/lp/soyuz/model/publishing.py 2013-05-14 06:33:24 +0000
@@ -1159,6 +1159,12 @@
1159 "component, section, priority and/or "1159 "component, section, priority and/or "
1160 "phased_update_percentage.")1160 "phased_update_percentage.")
11611161
1162 bpr = self.binarypackagerelease
1163 if bpr.binpackageformat == BinaryPackageFormat.DDEB:
1164 raise OverrideError(
1165 "Cannot override ddeb publications directly; override "
1166 "the corresponding deb instead.")
1167
1162 # Check there is a change to make1168 # Check there is a change to make
1163 if new_component is None:1169 if new_component is None:
1164 new_component = self.component1170 new_component = self.component
@@ -1300,6 +1306,12 @@
1300 "Cannot delete publications from suite '%s'" %1306 "Cannot delete publications from suite '%s'" %
1301 self.distroseries.getSuite(self.pocket))1307 self.distroseries.getSuite(self.pocket))
13021308
1309 bpr = self.binarypackagerelease
1310 if bpr.binpackageformat == BinaryPackageFormat.DDEB:
1311 raise DeletionError(
1312 "Cannot delete ddeb publications directly; delete the "
1313 "corresponding deb instead.")
1314
1303 self.setDeleted(removed_by, removal_comment)1315 self.setDeleted(removed_by, removal_comment)
13041316
1305 def binaryFileUrls(self, include_meta=False):1317 def binaryFileUrls(self, include_meta=False):
13061318
=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
--- lib/lp/soyuz/tests/test_publishing.py 2013-05-08 06:08:37 +0000
+++ lib/lp/soyuz/tests/test_publishing.py 2013-05-14 06:33:24 +0000
@@ -1056,6 +1056,22 @@
1056 [new_bpph])1056 [new_bpph])
1057 self.assertEqual(new_debug_bpph.section, new_section)1057 self.assertEqual(new_debug_bpph.section, new_section)
10581058
1059 def test_requestDeletion_forbids_debug_package(self):
1060 bpph, debug_bpph = self.factory.makeBinaryPackagePublishingHistory(
1061 pocket=PackagePublishingPocket.RELEASE, with_debug=True)
1062 self.assertRaisesWithContent(
1063 DeletionError, "Cannot delete ddeb publications directly; delete "
1064 "the corresponding deb instead.",
1065 debug_bpph.requestDeletion, self.factory.makePerson())
1066
1067 def test_changeOverride_forbids_debug_package(self):
1068 bpph, debug_bpph = self.factory.makeBinaryPackagePublishingHistory(
1069 pocket=PackagePublishingPocket.RELEASE, with_debug=True)
1070 self.assertRaisesWithContent(
1071 OverrideError, "Cannot override ddeb publications directly; "
1072 "override the corresponding deb instead.",
1073 debug_bpph.changeOverride, new_phased_update_percentage=20)
1074
10591075
1060class TestSourceDomination(TestNativePublishingBase):1076class TestSourceDomination(TestNativePublishingBase):
1061 """Test SourcePackagePublishingHistory.supersede() operates correctly."""1077 """Test SourcePackagePublishingHistory.supersede() operates correctly."""
10621078
=== modified file 'lib/lp/testing/__init__.py'
--- lib/lp/testing/__init__.py 2012-12-26 01:34:53 +0000
+++ lib/lp/testing/__init__.py 2013-05-14 06:33:24 +0000
@@ -573,13 +573,13 @@
573 self.assertThat(iter1, MatchesSetwise(*(map(Equals, iter2))))573 self.assertThat(iter1, MatchesSetwise(*(map(Equals, iter2))))
574574
575 def assertRaisesWithContent(self, exception, exception_content,575 def assertRaisesWithContent(self, exception, exception_content,
576 func, *args):576 func, *args, **kwargs):
577 """Check if the given exception is raised with given content.577 """Check if the given exception is raised with given content.
578578
579 If the exception isn't raised or the exception_content doesn't579 If the exception isn't raised or the exception_content doesn't
580 match what was raised an AssertionError is raised.580 match what was raised an AssertionError is raised.
581 """581 """
582 err = self.assertRaises(exception, func, *args)582 err = self.assertRaises(exception, func, *args, **kwargs)
583 self.assertEqual(exception_content, str(err))583 self.assertEqual(exception_content, str(err))
584584
585 def assertBetween(self, lower_bound, variable, upper_bound):585 def assertBetween(self, lower_bound, variable, upper_bound):