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
=== modified file 'lib/lp/answers/browser/tests/test_questiontarget.py'
--- lib/lp/answers/browser/tests/test_questiontarget.py 2012-01-01 02:58:52 +0000
+++ lib/lp/answers/browser/tests/test_questiontarget.py 2013-01-31 06:02:20 +0000
@@ -14,7 +14,6 @@
14 IWebServiceClientRequest,14 IWebServiceClientRequest,
15 )15 )
16from simplejson import dumps16from simplejson import dumps
17from storm.store import Store
18from zope.component import getUtility17from zope.component import getUtility
19from zope.security.proxy import removeSecurityProxy18from zope.security.proxy import removeSecurityProxy
20from zope.traversing.browser import absoluteURL19from zope.traversing.browser import absoluteURL
@@ -73,12 +72,7 @@
73 removeSecurityProxy(distro).official_answers = True72 removeSecurityProxy(distro).official_answers = True
74 dsp = self.factory.makeDistributionSourcePackage(73 dsp = self.factory.makeDistributionSourcePackage(
75 distribution=distro)74 distribution=distro)
76 questions = []75 [self.factory.makeQuestion(target=dsp, owner=owner) for i in range(5)]
77 for i in range(0, 5):
78 questions.append(self.factory.makeQuestion(
79 target=dsp, owner=owner))
80 # Empty the cache.
81 Store.of(questions[0]).invalidate()
82 browses_under_limit = BrowsesWithQueryLimit(76 browses_under_limit = BrowsesWithQueryLimit(
83 31, owner, view_name="+questions")77 31, owner, view_name="+questions")
84 self.assertThat(dsp, browses_under_limit)78 self.assertThat(dsp, browses_under_limit)
8579
=== modified file 'lib/lp/blueprints/browser/tests/test_specification.py'
--- lib/lp/blueprints/browser/tests/test_specification.py 2013-01-30 23:48:41 +0000
+++ lib/lp/blueprints/browser/tests/test_specification.py 2013-01-31 06:02:20 +0000
@@ -12,7 +12,6 @@
12from lazr.restful.interfaces import IJSONRequestCache12from lazr.restful.interfaces import IJSONRequestCache
13import pytz13import pytz
14import soupmatchers14import soupmatchers
15from storm.store import Store
16from testtools.matchers import (15from testtools.matchers import (
17 Equals,16 Equals,
18 Not,17 Not,
@@ -256,11 +255,9 @@
256 removeSecurityProxy(product).official_blueprints = True255 removeSecurityProxy(product).official_blueprints = True
257 self.factory.makeSpecification(product=product)256 self.factory.makeSpecification(product=product)
258 limit = BrowsesWithQueryLimit(37, product.owner, rootsite='blueprints')257 limit = BrowsesWithQueryLimit(37, product.owner, rootsite='blueprints')
259 Store.of(product).invalidate()
260 self.assertThat(product, limit)258 self.assertThat(product, limit)
261 login_celebrity('admin')259 login_celebrity('admin')
262 [self.factory.makeSpecification(product=product) for i in range(4)]260 [self.factory.makeSpecification(product=product) for i in range(4)]
263 Store.of(product).invalidate()
264 self.assertThat(product, limit)261 self.assertThat(product, limit)
265 262
266263
267264
=== modified file 'lib/lp/blueprints/browser/tests/test_sprint.py'
--- lib/lp/blueprints/browser/tests/test_sprint.py 2012-11-26 08:33:03 +0000
+++ lib/lp/blueprints/browser/tests/test_sprint.py 2013-01-31 06:02:20 +0000
@@ -5,7 +5,6 @@
55
6__metaclass__ = type6__metaclass__ = type
77
8from storm.locals import Store
9from testtools.matchers import Equals8from testtools.matchers import Equals
109
11from lp.app.enums import InformationType10from lp.app.enums import InformationType
@@ -27,11 +26,7 @@
27 for x in range(30):26 for x in range(30):
28 sprint.attend(27 sprint.attend(
29 self.factory.makePerson(),28 self.factory.makePerson(),
30 sprint.time_starts,29 sprint.time_starts, sprint.time_ends, True)
31 sprint.time_ends,
32 True)
33 Store.of(sprint).flush()
34 Store.of(sprint).invalidate()
35 self.assertThat(sprint, BrowsesWithQueryLimit(18, sprint.owner))30 self.assertThat(sprint, BrowsesWithQueryLimit(18, sprint.owner))
3631
37 def test_blueprint_listing_query_count(self):32 def test_blueprint_listing_query_count(self):
3833
=== modified file 'lib/lp/testing/matchers.py'
--- lib/lp/testing/matchers.py 2012-06-29 08:40:05 +0000
+++ lib/lp/testing/matchers.py 2013-01-31 06:02:20 +0000
@@ -43,6 +43,7 @@
43 Proxy,43 Proxy,
44 )44 )
4545
46from lp.services.database.sqlbase import flush_database_caches
46from lp.services.webapp import canonical_url47from lp.services.webapp import canonical_url
47from lp.services.webapp.batching import BatchNavigator48from lp.services.webapp.batching import BatchNavigator
48from lp.testing import normalize_whitespace49from lp.testing import normalize_whitespace
@@ -78,6 +79,7 @@
78 context_url = canonical_url(79 context_url = canonical_url(
79 context, view_name=self.view_name, **self.options)80 context, view_name=self.view_name, **self.options)
80 browser = setupBrowserForUser(self.user)81 browser = setupBrowserForUser(self.user)
82 flush_database_caches()
81 collector = QueryCollector()83 collector = QueryCollector()
82 collector.register()84 collector.register()
83 try:85 try: