Merge lp:~twom/launchpad/precache-gitrepository-branch-queries into lp:launchpad

Proposed by Tom Wardill
Status: Merged
Merged at revision: 18770
Proposed branch: lp:~twom/launchpad/precache-gitrepository-branch-queries
Merge into: lp:launchpad
Diff against target: 58 lines (+6/-4)
3 files modified
lib/lp/code/browser/tests/test_branch.py (+2/-2)
lib/lp/code/browser/tests/test_gitref.py (+2/-2)
lib/lp/code/tests/helpers.py (+2/-0)
To merge this branch: bzr merge lp:~twom/launchpad/precache-gitrepository-branch-queries
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+354470@code.launchpad.net

Commit message

Fix tests broken by the change to a cachedproperty

Description of the change

BranchMergeProposal.votes changed to a cachedproperty, this changes tests to clear that cache once the BMP is loaded and altered.

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

I agree with your comment on IRC that it seems like you have too many calls to `clear_property_cache`, and I think that's because you're doing this slightly too far up the call stack. Try instead doing this in `make_merge_proposal_without_reviewers`, though in a more targeted form: `del get_property_cache(proposal).votes` after removing the votes. Then try removing all your `clear_property_cache` calls and see which ones you really need after that.

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
1=== modified file 'lib/lp/code/browser/tests/test_branch.py'
2--- lib/lp/code/browser/tests/test_branch.py 2018-06-22 10:01:34 +0000
3+++ lib/lp/code/browser/tests/test_branch.py 2018-09-07 13:47:31 +0000
4@@ -568,7 +568,7 @@
5 view = create_view(branch, '+index')
6 with StormStatementRecorder() as recorder:
7 view.landing_candidates
8- self.assertThat(recorder, HasQueryCount(Equals(13)))
9+ self.assertThat(recorder, HasQueryCount(Equals(14)))
10
11 def test_query_count_landing_targets(self):
12 product = self.factory.makeProduct()
13@@ -586,7 +586,7 @@
14 view = create_view(branch, '+index')
15 with StormStatementRecorder() as recorder:
16 view.landing_targets
17- self.assertThat(recorder, HasQueryCount(Equals(12)))
18+ self.assertThat(recorder, HasQueryCount(Equals(13)))
19
20 def test_query_count_subscriber_content(self):
21 branch = self.factory.makeBranch()
22
23=== modified file 'lib/lp/code/browser/tests/test_gitref.py'
24--- lib/lp/code/browser/tests/test_gitref.py 2018-08-24 16:52:27 +0000
25+++ lib/lp/code/browser/tests/test_gitref.py 2018-09-07 13:47:31 +0000
26@@ -295,7 +295,7 @@
27 view = create_view(ref, '+index')
28 with StormStatementRecorder() as recorder:
29 view.landing_candidates
30- self.assertThat(recorder, HasQueryCount(Equals(11)))
31+ self.assertThat(recorder, HasQueryCount(Equals(12)))
32
33 def test_query_count_landing_targets(self):
34 project = self.factory.makeProduct()
35@@ -311,4 +311,4 @@
36 view = create_view(ref, '+index')
37 with StormStatementRecorder() as recorder:
38 view.landing_targets
39- self.assertThat(recorder, HasQueryCount(Equals(11)))
40+ self.assertThat(recorder, HasQueryCount(Equals(12)))
41
42=== modified file 'lib/lp/code/tests/helpers.py'
43--- lib/lp/code/tests/helpers.py 2018-05-17 14:10:29 +0000
44+++ lib/lp/code/tests/helpers.py 2018-09-07 13:47:31 +0000
45@@ -49,6 +49,7 @@
46 from lp.registry.interfaces.pocket import PackagePublishingPocket
47 from lp.registry.interfaces.series import SeriesStatus
48 from lp.services.database.sqlbase import cursor
49+from lp.services.propertycache import get_property_cache
50 from lp.services.memcache.testing import MemcacheFixture
51 from lp.testing import (
52 run_with_login,
53@@ -275,6 +276,7 @@
54 proposal = factory.makeBranchMergeProposal(**kwargs)
55 for vote in proposal.votes:
56 removeSecurityProxy(vote).destroySelf()
57+ del get_property_cache(proposal).votes
58 return proposal
59
60