launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29434
[Merge] ~cjwatson/launchpad:factory-proxy-git-rule into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:factory-proxy-git-rule into launchpad:master.
Commit message:
Return proxied objects from makeGitRule and makeGitRuleGrant
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/433646
`LaunchpadObjectFactory` issues `UnproxiedFactoryMethodWarning` when its methods return objects not wrapped in a security proxy, since that tends to result in tests that are less accurate simulations of production.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:factory-proxy-git-rule into launchpad:master.
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index 794ab5e..5f27dff 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -2149,7 +2149,9 @@ class LaunchpadObjectFactory(ObjectFactory):
if creator is None:
creator = repository.owner
with person_logged_in(creator):
- return repository.addRule(ref_pattern, creator, position=position)
+ return ProxyFactory(
+ repository.addRule(ref_pattern, creator, position=position)
+ )
def makeGitRuleGrant(
self,
@@ -2167,14 +2169,16 @@ class LaunchpadObjectFactory(ObjectFactory):
if grantee is None:
grantee = self.makePerson()
if grantor is None:
- grantor = rule.repository.owner
+ grantor = removeSecurityProxy(rule).repository.owner
with person_logged_in(grantor):
- return rule.addGrant(
- grantee,
- grantor,
- can_create=can_create,
- can_push=can_push,
- can_force_push=can_force_push,
+ return ProxyFactory(
+ rule.addGrant(
+ grantee,
+ grantor,
+ can_create=can_create,
+ can_push=can_push,
+ can_force_push=can_force_push,
+ )
)
def makeRevisionStatusReport(