Merge lp:~stevenk/launchpad/browseswithquerylimit-invalidates into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: Steve Kowalik
Approved revision: no longer in the source branch.
Merged at revision: 16460
Proposed branch: lp:~stevenk/launchpad/browseswithquerylimit-invalidates
Merge into: lp:launchpad
Diff against target: 94 lines (+4/-16)
4 files modified
lib/lp/answers/browser/tests/test_questiontarget.py (+1/-7)
lib/lp/blueprints/browser/tests/test_specification.py (+0/-3)
lib/lp/blueprints/browser/tests/test_sprint.py (+1/-6)
lib/lp/testing/matchers.py (+2/-0)
To merge this branch: bzr merge lp:~stevenk/launchpad/browseswithquerylimit-invalidates
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+145774@code.launchpad.net

Commit message

Invalidate all stores inside the match function for BrowsesWithQueryLimit, which saves the tests from doing so.

Description of the change

Invalidate all stores inside the match function for BrowsesWithQueryLimit, saves the tests doing so. Clean up tests that bothered to do it, and sighed at the others that did not.

To post a comment you must log in.
Revision history for this message
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/answers/browser/tests/test_questiontarget.py'
2--- lib/lp/answers/browser/tests/test_questiontarget.py 2012-01-01 02:58:52 +0000
3+++ lib/lp/answers/browser/tests/test_questiontarget.py 2013-01-31 06:02:20 +0000
4@@ -14,7 +14,6 @@
5 IWebServiceClientRequest,
6 )
7 from simplejson import dumps
8-from storm.store import Store
9 from zope.component import getUtility
10 from zope.security.proxy import removeSecurityProxy
11 from zope.traversing.browser import absoluteURL
12@@ -73,12 +72,7 @@
13 removeSecurityProxy(distro).official_answers = True
14 dsp = self.factory.makeDistributionSourcePackage(
15 distribution=distro)
16- questions = []
17- for i in range(0, 5):
18- questions.append(self.factory.makeQuestion(
19- target=dsp, owner=owner))
20- # Empty the cache.
21- Store.of(questions[0]).invalidate()
22+ [self.factory.makeQuestion(target=dsp, owner=owner) for i in range(5)]
23 browses_under_limit = BrowsesWithQueryLimit(
24 31, owner, view_name="+questions")
25 self.assertThat(dsp, browses_under_limit)
26
27=== modified file 'lib/lp/blueprints/browser/tests/test_specification.py'
28--- lib/lp/blueprints/browser/tests/test_specification.py 2013-01-30 23:48:41 +0000
29+++ lib/lp/blueprints/browser/tests/test_specification.py 2013-01-31 06:02:20 +0000
30@@ -12,7 +12,6 @@
31 from lazr.restful.interfaces import IJSONRequestCache
32 import pytz
33 import soupmatchers
34-from storm.store import Store
35 from testtools.matchers import (
36 Equals,
37 Not,
38@@ -256,11 +255,9 @@
39 removeSecurityProxy(product).official_blueprints = True
40 self.factory.makeSpecification(product=product)
41 limit = BrowsesWithQueryLimit(37, product.owner, rootsite='blueprints')
42- Store.of(product).invalidate()
43 self.assertThat(product, limit)
44 login_celebrity('admin')
45 [self.factory.makeSpecification(product=product) for i in range(4)]
46- Store.of(product).invalidate()
47 self.assertThat(product, limit)
48
49
50
51=== modified file 'lib/lp/blueprints/browser/tests/test_sprint.py'
52--- lib/lp/blueprints/browser/tests/test_sprint.py 2012-11-26 08:33:03 +0000
53+++ lib/lp/blueprints/browser/tests/test_sprint.py 2013-01-31 06:02:20 +0000
54@@ -5,7 +5,6 @@
55
56 __metaclass__ = type
57
58-from storm.locals import Store
59 from testtools.matchers import Equals
60
61 from lp.app.enums import InformationType
62@@ -27,11 +26,7 @@
63 for x in range(30):
64 sprint.attend(
65 self.factory.makePerson(),
66- sprint.time_starts,
67- sprint.time_ends,
68- True)
69- Store.of(sprint).flush()
70- Store.of(sprint).invalidate()
71+ sprint.time_starts, sprint.time_ends, True)
72 self.assertThat(sprint, BrowsesWithQueryLimit(18, sprint.owner))
73
74 def test_blueprint_listing_query_count(self):
75
76=== modified file 'lib/lp/testing/matchers.py'
77--- lib/lp/testing/matchers.py 2012-06-29 08:40:05 +0000
78+++ lib/lp/testing/matchers.py 2013-01-31 06:02:20 +0000
79@@ -43,6 +43,7 @@
80 Proxy,
81 )
82
83+from lp.services.database.sqlbase import flush_database_caches
84 from lp.services.webapp import canonical_url
85 from lp.services.webapp.batching import BatchNavigator
86 from lp.testing import normalize_whitespace
87@@ -78,6 +79,7 @@
88 context_url = canonical_url(
89 context, view_name=self.view_name, **self.options)
90 browser = setupBrowserForUser(self.user)
91+ flush_database_caches()
92 collector = QueryCollector()
93 collector.register()
94 try: