Merge ~cjwatson/launchpad:export-is-stale into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: ef65c0428813fdf3526cce1e810a2841f98cb039
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:export-is-stale
Merge into: launchpad:master
Diff against target: 98 lines (+26/-5)
5 files modified
lib/lp/code/interfaces/sourcepackagerecipe.py (+3/-2)
lib/lp/code/model/gitrepository.py (+4/-1)
lib/lp/code/model/tests/test_sourcepackagerecipe.py (+8/-0)
lib/lp/snappy/interfaces/snap.py (+2/-2)
lib/lp/snappy/tests/test_snap.py (+9/-0)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+402642@code.launchpad.net

Commit message

Export read-only is_stale attribute on recipes

Description of the change

This is useful for debugging.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/code/interfaces/sourcepackagerecipe.py b/lib/lp/code/interfaces/sourcepackagerecipe.py
index b499ccd..3d9d3ab 100644
--- a/lib/lp/code/interfaces/sourcepackagerecipe.py
+++ b/lib/lp/code/interfaces/sourcepackagerecipe.py
@@ -1,4 +1,4 @@
1# Copyright 2009-2018 Canonical Ltd. This software is licensed under the1# Copyright 2009-2021 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Interface of the `SourcePackageRecipe` content type."""4"""Interface of the `SourcePackageRecipe` content type."""
@@ -277,7 +277,8 @@ class ISourcePackageRecipeEditableAttributes(IHasOwner):
277 date_last_modified = exported(277 date_last_modified = exported(
278 Datetime(required=True, readonly=True))278 Datetime(required=True, readonly=True))
279279
280 is_stale = Bool(title=_('Recipe is stale.'))280 is_stale = exported(
281 Bool(title=_('Recipe is stale.'), required=True, readonly=True))
281282
282283
283class ISourcePackageRecipeEdit(Interface):284class ISourcePackageRecipeEdit(Interface):
diff --git a/lib/lp/code/model/gitrepository.py b/lib/lp/code/model/gitrepository.py
index 2ba9491..d447abb 100644
--- a/lib/lp/code/model/gitrepository.py
+++ b/lib/lp/code/model/gitrepository.py
@@ -1272,7 +1272,10 @@ class GitRepository(StormBase, WebhookTargetMixin, GitIdentityMixin):
1272 paths=paths,1272 paths=paths,
1273 check_permissions=False)1273 check_permissions=False)
1274 for snap in snaps:1274 for snap in snaps:
1275 snap.is_stale = True1275 # ISnapSet.findByGitRepository returns security-proxied Snap
1276 # objects on which the is_stale attribute is read-only. Bypass
1277 # this.
1278 removeSecurityProxy(snap).is_stale = True
12761279
1277 def _markProposalMerged(self, proposal, merged_revision_id, logger=None):1280 def _markProposalMerged(self, proposal, merged_revision_id, logger=None):
1278 if logger is not None:1281 if logger is not None:
diff --git a/lib/lp/code/model/tests/test_sourcepackagerecipe.py b/lib/lp/code/model/tests/test_sourcepackagerecipe.py
index 514521f..b14b8ab 100644
--- a/lib/lp/code/model/tests/test_sourcepackagerecipe.py
+++ b/lib/lp/code/model/tests/test_sourcepackagerecipe.py
@@ -14,6 +14,7 @@ from datetime import (
14import textwrap14import textwrap
1515
16from breezy.plugins.builder.recipe import ForbiddenInstructionError16from breezy.plugins.builder.recipe import ForbiddenInstructionError
17from lazr.restfulclient.errors import BadRequest
17from pytz import UTC18from pytz import UTC
18from storm.locals import Store19from storm.locals import Store
19from testtools.matchers import Equals20from testtools.matchers import Equals
@@ -1232,6 +1233,13 @@ class TestWebserviceMixin:
1232 recipe.setRecipeText(recipe_text=recipe_text2)1233 recipe.setRecipeText(recipe_text=recipe_text2)
1233 self.assertEqual(recipe_text2, recipe.recipe_text)1234 self.assertEqual(recipe_text2, recipe.recipe_text)
12341235
1236 def test_is_stale(self):
1237 """is_stale is exported and is read-only."""
1238 recipe = self.makeRecipe()[0]
1239 self.assertTrue(recipe.is_stale)
1240 recipe.is_stale = False
1241 self.assertRaises(BadRequest, recipe.lp_save)
1242
1235 def test_getRecipe(self):1243 def test_getRecipe(self):
1236 """Person.getRecipe returns the named recipe."""1244 """Person.getRecipe returns the named recipe."""
1237 recipe, user = self.makeRecipe()[:-1]1245 recipe, user = self.makeRecipe()[:-1]
diff --git a/lib/lp/snappy/interfaces/snap.py b/lib/lp/snappy/interfaces/snap.py
index f2ce156..16fd213 100644
--- a/lib/lp/snappy/interfaces/snap.py
+++ b/lib/lp/snappy/interfaces/snap.py
@@ -827,9 +827,9 @@ class ISnapEditableAttributes(IHasOwner):
827 "this snap package. Currently only 'core', 'core18', "827 "this snap package. Currently only 'core', 'core18', "
828 "'core20' and 'snapcraft' keys are supported.")))828 "'core20' and 'snapcraft' keys are supported.")))
829829
830 is_stale = Bool(830 is_stale = exported(Bool(
831 title=_("Snap package is stale and is due to be rebuilt."),831 title=_("Snap package is stale and is due to be rebuilt."),
832 required=True, readonly=False)832 required=True, readonly=True))
833833
834 store_upload = exported(Bool(834 store_upload = exported(Bool(
835 title=_("Automatically upload to store"),835 title=_("Automatically upload to store"),
diff --git a/lib/lp/snappy/tests/test_snap.py b/lib/lp/snappy/tests/test_snap.py
index be338d7..bb6c659 100644
--- a/lib/lp/snappy/tests/test_snap.py
+++ b/lib/lp/snappy/tests/test_snap.py
@@ -3039,6 +3039,15 @@ class TestSnapWebservice(TestCaseWithFactory):
3039 "git_path": Equals("HEAD"),3039 "git_path": Equals("HEAD"),
3040 }))3040 }))
30413041
3042 def test_is_stale(self):
3043 # is_stale is exported and is read-only.
3044 snap = self.makeSnap()
3045 self.assertTrue(snap["is_stale"])
3046 response = self.webservice.patch(
3047 snap["self_link"], "application/json",
3048 json.dumps({"is_stale": False}))
3049 self.assertEqual(400, response.status)
3050
3042 def test_getByName(self):3051 def test_getByName(self):
3043 # lp.snaps.getByName returns a matching Snap.3052 # lp.snaps.getByName returns a matching Snap.
3044 snap = self.makeSnap()3053 snap = self.makeSnap()

Subscribers

People subscribed via source and target branches

to status/vote changes: