Merge ~cjwatson/launchpad:factory-proxy-branchrevision into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: af059732077fe142aaf162ace173f0e0e942f9ae
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:factory-proxy-branchrevision
Merge into: launchpad:master
Diff against target: 34 lines (+3/-3)
2 files modified
lib/lp/code/model/tests/test_diff.py (+2/-2)
lib/lp/testing/factory.py (+1/-1)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+434695@code.launchpad.net

Commit message

Return proxied objects from makeBranchRevision

Description of the change

`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.

This required tightening up one test.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) :
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/tests/test_diff.py b/lib/lp/code/model/tests/test_diff.py
2index 833e04e..afb7d90 100644
3--- a/lib/lp/code/model/tests/test_diff.py
4+++ b/lib/lp/code/model/tests/test_diff.py
5@@ -482,14 +482,14 @@ class TestPreviewDiff(DiffTestCase):
6 )
7 self.assertEqual("rev-a into rev-b", preview.title)
8 # Revision number is used only when it (sequence) is defined.
9- source_rev.sequence = 10
10+ removeSecurityProxy(source_rev).sequence = 10
11 self.assertEqual("r10 into rev-b", preview.title)
12 # Same behavior is applied to the target_branch information.
13 target_rev = self.factory.makeBranchRevision(
14 branch=mp.target_branch, revision_id="rev-b", sequence=None
15 )
16 self.assertEqual("r10 into rev-b", preview.title)
17- target_rev.sequence = 1
18+ removeSecurityProxy(target_rev).sequence = 1
19 self.assertEqual("r10 into r1", preview.title)
20
21 def test_title_git(self):
22diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
23index 40a959c..3df643f 100644
24--- a/lib/lp/testing/factory.py
25+++ b/lib/lp/testing/factory.py
26@@ -2038,7 +2038,7 @@ class LaunchpadObjectFactory(ObjectFactory):
27 parent_ids=parent_ids,
28 revision_date=revision_date,
29 )
30- return branch.createBranchRevision(sequence, revision)
31+ return ProxyFactory(branch.createBranchRevision(sequence, revision))
32
33 def makeGitRepository(
34 self,

Subscribers

People subscribed via source and target branches

to status/vote changes: