Merge lp:~wallyworld/launchpad/create-aag-privacy-transitions-followup2 into lp:launchpad

Proposed by Ian Booth on 2012-06-19
Status: Merged
Approved by: Ian Booth on 2012-06-19
Approved revision: no longer in the source branch.
Merged at revision: 15438
Proposed branch: lp:~wallyworld/launchpad/create-aag-privacy-transitions-followup2
Merge into: lp:launchpad
Diff against target: 86 lines (+21/-9)
2 files modified
lib/lp/registry/services/sharingservice.py (+6/-5)
lib/lp/registry/services/tests/test_sharingservice.py (+15/-4)
To merge this branch: bzr merge lp:~wallyworld/launchpad/create-aag-privacy-transitions-followup2
Reviewer Review Type Date Requested Status
William Grant code 2012-06-19 Approve on 2012-06-19
Review via email: mp+110945@code.launchpad.net

Commit Message

Fix an issue with the query used for ISharingService.getPeopleWithoutAccess() and enhance the unit test.

Description of the Change

== Implementation ==

Query the people who do have access and subtract these from the set of people passed in.

== Tests ==

Enhance the existing unit test.

== Lint ==

Linting changed files:
  lib/lp/registry/services/sharingservice.py
  lib/lp/registry/services/tests/test_sharingservice.py

To post a comment you must log in.
William Grant (wgrant) :
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/registry/services/sharingservice.py'
2--- lib/lp/registry/services/sharingservice.py 2012-06-18 11:53:11 +0000
3+++ lib/lp/registry/services/sharingservice.py 2012-06-19 03:31:20 +0000
4@@ -18,7 +18,7 @@
5 And,
6 In,
7 Join,
8- Not,
9+ Or,
10 Select,
11 )
12 from zope.component import getUtility
13@@ -167,6 +167,7 @@
14 AccessArtifactGrant.abstract_artifact_id ==
15 access_artifact.id)))
16
17+ # Find the people who can see the artifacts.
18 person_ids = [person.id for person in people]
19 store = IStore(AccessArtifactGrant)
20 tables = [
21@@ -174,12 +175,12 @@
22 Join(TeamParticipation, TeamParticipation.personID == Person.id)]
23 result_set = store.using(*tables).find(
24 Person,
25- And(
26- Not(In(TeamParticipation.teamID, policy_grantees)),
27- Not(In(TeamParticipation.teamID, artifact_grantees))),
28+ Or(
29+ In(TeamParticipation.teamID, policy_grantees),
30+ In(TeamParticipation.teamID, artifact_grantees)),
31 In(Person.id, person_ids))
32
33- return result_set
34+ return set(people).difference(set(result_set))
35
36 def getInformationTypes(self, pillar):
37 """See `ISharingService`."""
38
39=== modified file 'lib/lp/registry/services/tests/test_sharingservice.py'
40--- lib/lp/registry/services/tests/test_sharingservice.py 2012-06-19 02:14:21 +0000
41+++ lib/lp/registry/services/tests/test_sharingservice.py 2012-06-19 03:31:20 +0000
42@@ -1057,11 +1057,22 @@
43 product = self.factory.makeProduct(owner=owner)
44 login_person(owner)
45
46- # Make some people to check.
47+ # Make some people to check. people[:5] will not have access.
48 people = []
49+ # Make a team with access.
50+ member_with_access = self.factory.makePerson()
51+ team_with_access = self.factory.makeTeam(members=[member_with_access])
52+ # Make a team without access.
53+ team_without_access = (
54+ self.factory.makeTeam(members=[member_with_access]))
55+ people.append(team_without_access)
56 for x in range(0, 10):
57 person = self.factory.makePerson()
58 people.append(person)
59+ people.append(team_with_access)
60+ people.append(member_with_access)
61+
62+ # Make the bug to use.
63 bug = self.factory.makeBug(
64 product=product, owner=owner,
65 information_type=InformationType.USERDATA)
66@@ -1071,17 +1082,17 @@
67 # Some access policy grants.
68 [policy] = getUtility(IAccessPolicySource).find(
69 [(product, InformationType.USERDATA)])
70- for person in people[:2]:
71+ for person in people[5:7]:
72 self.factory.makeAccessPolicyGrant(
73 policy=policy, grantee=person, grantor=owner)
74 # Some access artifact grants.
75- for person in people[2:5]:
76+ for person in people[7:]:
77 self.factory.makeAccessArtifactGrant(
78 artifact=access_artifact, grantee=person, grantor=owner)
79
80 # Check the results.
81 without_access = self.service.getPeopleWithoutAccess(bug, people)
82- self.assertContentEqual(people[5:], without_access)
83+ self.assertContentEqual(people[:5], without_access)
84
85 def test_getVisibleArtifacts(self):
86 # Test the getVisibleArtifacts method.