Merge launchpad:master into launchpad:db-devel

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 0ae05b82a9b984ea0c0221d9284ef9a655cbf632
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: launchpad:master
Merge into: launchpad:db-devel
Diff against target: 70 lines (+36/-1)
3 files modified
lib/lp/code/model/branch.py (+3/-1)
lib/lp/snappy/browser/snap.py (+4/-0)
lib/lp/snappy/browser/tests/test_snap.py (+29/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+402985@code.launchpad.net

Commit message

Manually merge from master to fix test_bzrsync.TestMarkSnapsStale failures

Description of the change

These sneaked through to db-devel due to a buildbot subunit parsing bug of some kind.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/code/model/branch.py b/lib/lp/code/model/branch.py
2index 452bf4e..c9a98cd 100644
3--- a/lib/lp/code/model/branch.py
4+++ b/lib/lp/code/model/branch.py
5@@ -689,7 +689,9 @@ class Branch(SQLBase, WebhookTargetMixin, BzrIdentityMixin):
6 self,
7 check_permissions=False)
8 for snap in snaps:
9- snap.is_stale = True
10+ # ISnapSet.findByBranch returns security-proxied Snap objects on
11+ # which the is_stale attribute is read-only. Bypass this.
12+ removeSecurityProxy(snap).is_stale = True
13
14 def addToLaunchBag(self, launchbag):
15 """See `IBranch`."""
16diff --git a/lib/lp/snappy/browser/snap.py b/lib/lp/snappy/browser/snap.py
17index ac7925c..c7b0ea3 100644
18--- a/lib/lp/snappy/browser/snap.py
19+++ b/lib/lp/snappy/browser/snap.py
20@@ -835,6 +835,10 @@ class BaseSnapEditView(SnapAuthorizeMixin, SnapInformationTypeMixin,
21 if 'store_channels' in data:
22 del data['store_channels']
23 need_store_reauth = self._needStoreReauth(data)
24+ info_type = data.get('information_type')
25+ if info_type and info_type != self.context.information_type:
26+ self.context.information_type = info_type
27+ del data['information_type']
28 self.updateContextFromData(data)
29 if need_store_reauth:
30 self.requestAuthorization(self.context)
31diff --git a/lib/lp/snappy/browser/tests/test_snap.py b/lib/lp/snappy/browser/tests/test_snap.py
32index 486e586..8a96e17 100644
33--- a/lib/lp/snappy/browser/tests/test_snap.py
34+++ b/lib/lp/snappy/browser/tests/test_snap.py
35@@ -1150,6 +1150,35 @@ class TestSnapEditView(BaseTestSnapView):
36 "A public snap cannot have a private owner.",
37 extract_text(find_tags_by_class(browser.contents, "message")[1]))
38
39+ def test_edit_public_snap_make_private_in_one_go(self):
40+ # Move a public snap to a private owner and mark it private in one go
41+ series = self.factory.makeUbuntuDistroSeries()
42+ with admin_logged_in():
43+ snappy_series = self.factory.makeSnappySeries(
44+ usable_distro_series=[series])
45+ login_person(self.person)
46+ private_project = self.factory.makeProduct(
47+ name='private-project',
48+ owner=self.person, registrant=self.person,
49+ information_type=InformationType.PROPRIETARY,
50+ branch_sharing_policy=BranchSharingPolicy.PROPRIETARY)
51+ snap = self.factory.makeSnap(
52+ registrant=self.person, owner=self.person, distroseries=series,
53+ store_series=snappy_series, project=private_project)
54+ private_team = self.factory.makeTeam(
55+ owner=self.person, visibility=PersonVisibility.PRIVATE)
56+ private_team_name = private_team.name
57+
58+ browser = self.getViewBrowser(snap, user=self.person)
59+ browser.getLink("Edit snap package").click()
60+ browser.getControl("Owner").value = [private_team_name]
61+ browser.getControl(name="field.information_type").value = (
62+ "PROPRIETARY")
63+ browser.getControl("Update snap package").click()
64+
65+ login_admin()
66+ self.assertEqual(InformationType.PROPRIETARY, snap.information_type)
67+
68 def test_edit_public_snap_private_branch(self):
69 series = self.factory.makeUbuntuDistroSeries()
70 with admin_logged_in():

Subscribers

People subscribed via source and target branches

to status/vote changes: