Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2044)

Unified Diff: dashboard/dashboard/datastore_hooks_test.py

Issue 2350113002: Add request-level caching for privileged queries. (Closed)
Patch Set: Addressed review comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dashboard/dashboard/datastore_hooks.py ('k') | dashboard/dashboard/layered_cache_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dashboard/dashboard/datastore_hooks_test.py
diff --git a/dashboard/dashboard/datastore_hooks_test.py b/dashboard/dashboard/datastore_hooks_test.py
index 05cd228aca50ecb32e0c9d0655d14190a4ed956a..d117bd2edc9519a60e7ed2ad703cb0787844c00f 100644
--- a/dashboard/dashboard/datastore_hooks_test.py
+++ b/dashboard/dashboard/datastore_hooks_test.py
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import unittest
+import webapp2
from google.appengine.ext import ndb
@@ -175,6 +176,13 @@ class DatastoreHooksTest(testing_common.TestCase):
self.assertEqual(1, len(sheriffs))
self.assertEqual('external', sheriffs[0].key.string_id())
self.assertEqual('foo@chromium.org', sheriffs[0].email)
+ request = webapp2.get_request()
+ if request.registry.get('single_privileged') is not None:
+ self.assertIsNone(request.registry.get('privileged_cached'))
+ elif include_internal:
+ self.assertTrue(request.registry.get('privileged_cached'))
+ else:
+ self.assertFalse(request.registry.get('privileged_cached'))
def testQuery_NoUser_InternalOnlyNotFetched(self):
self.UnsetCurrentUser()
@@ -261,6 +269,13 @@ class DatastoreHooksTest(testing_common.TestCase):
datastore_hooks.SetPrivilegedRequest()
self._CheckGet(include_internal=True)
+ def testGet_CachedPrivilege(self):
+ request = webapp2.get_request()
+ request.registry['privileged_cached'] = True
+ self._CheckGet(include_internal=True)
+ request.registry['privileged_cached'] = False
+ self._CheckGet(include_internal=False)
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « dashboard/dashboard/datastore_hooks.py ('k') | dashboard/dashboard/layered_cache_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698