← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/browseswithquerylimit-invalidates into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/browseswithquerylimit-invalidates/+merge/145774

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.
-- 
https://code.launchpad.net/~stevenk/launchpad/browseswithquerylimit-invalidates/+merge/145774
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/browseswithquerylimit-invalidates into lp:launchpad.
=== 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 05:44:22 +0000
@@ -14,7 +14,6 @@
     IWebServiceClientRequest,
     )
 from simplejson import dumps
-from storm.store import Store
 from zope.component import getUtility
 from zope.security.proxy import removeSecurityProxy
 from zope.traversing.browser import absoluteURL
@@ -77,8 +76,6 @@
         for i in range(0, 5):
             questions.append(self.factory.makeQuestion(
                 target=dsp, owner=owner))
-        # Empty the cache.
-        Store.of(questions[0]).invalidate()
         browses_under_limit = BrowsesWithQueryLimit(
             31, owner, view_name="+questions")
         self.assertThat(dsp, browses_under_limit)

=== 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 05:44:22 +0000
@@ -12,7 +12,6 @@
 from lazr.restful.interfaces import IJSONRequestCache
 import pytz
 import soupmatchers
-from storm.store import Store
 from testtools.matchers import (
     Equals,
     Not,
@@ -256,11 +255,9 @@
         removeSecurityProxy(product).official_blueprints = True
         self.factory.makeSpecification(product=product)
         limit = BrowsesWithQueryLimit(37, product.owner, rootsite='blueprints')
-        Store.of(product).invalidate()
         self.assertThat(product, limit)
         login_celebrity('admin')
         [self.factory.makeSpecification(product=product) for i in range(4)]
-        Store.of(product).invalidate()
         self.assertThat(product, limit)
         
 

=== 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 05:44:22 +0000
@@ -31,7 +31,6 @@
                 sprint.time_ends,
                 True)
         Store.of(sprint).flush()
-        Store.of(sprint).invalidate()
         self.assertThat(sprint, BrowsesWithQueryLimit(18, sprint.owner))
 
     def test_blueprint_listing_query_count(self):

=== 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 05:44:22 +0000
@@ -43,6 +43,7 @@
     Proxy,
     )
 
+from lp.services.database.sqlbase import flush_database_caches
 from lp.services.webapp import canonical_url
 from lp.services.webapp.batching import BatchNavigator
 from lp.testing import normalize_whitespace
@@ -80,6 +81,7 @@
         browser = setupBrowserForUser(self.user)
         collector = QueryCollector()
         collector.register()
+        flush_database_caches()
         try:
             browser.open(context_url)
             counter = HasQueryCount(LessThan(self.query_limit))