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

Side by Side Diff: dashboard/dashboard/models/internal_only_model_test.py

Issue 2350113002: Add request-level caching for privileged queries. (Closed)
Patch Set: Fix unit tests 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 unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import unittest 5 import unittest
6 6
7 import mock 7 import mock
8 8
9 from google.appengine.ext import ndb 9 from google.appengine.ext import ndb
10 10
(...skipping 15 matching lines...) Expand all
26 def CreateCallback(self): 26 def CreateCallback(self):
27 pass 27 pass
28 28
29 29
30 class InternalOnlyModelTest(testing_common.TestCase): 30 class InternalOnlyModelTest(testing_common.TestCase):
31 31
32 def setUp(self): 32 def setUp(self):
33 super(InternalOnlyModelTest, self).setUp() 33 super(InternalOnlyModelTest, self).setUp()
34 testing_common.SetIsInternalUser('x@google.com', True) 34 testing_common.SetIsInternalUser('x@google.com', True)
35 testing_common.SetIsInternalUser('x@foo.com', False) 35 testing_common.SetIsInternalUser('x@foo.com', False)
36 self.PatchDatastoreHooksRequest()
36 37
37 def testInternalOnlyModel_InternalUser_EntityFetched(self): 38 def testInternalOnlyModel_InternalUser_EntityFetched(self):
38 key = InternalOnlyModelExample(internal_only=True).put() 39 key = InternalOnlyModelExample(internal_only=True).put()
39 self.SetCurrentUser('x@google.com') 40 self.SetCurrentUser('x@google.com')
40 self.assertEqual(key, key.get().key) 41 self.assertEqual(key, key.get().key)
41 42
42 def testInternalOnlyModel_ExternalUserInternalEntity_AssertionRaised(self): 43 def testInternalOnlyModel_ExternalUserInternalEntity_AssertionRaised(self):
43 key = InternalOnlyModelExample(internal_only=True).put() 44 key = InternalOnlyModelExample(internal_only=True).put()
44 self.SetCurrentUser('x@foo.com') 45 self.SetCurrentUser('x@foo.com')
45 with self.assertRaises(AssertionError): 46 with self.assertRaises(AssertionError):
(...skipping 30 matching lines...) Expand all
76 key.get() 77 key.get()
77 78
78 def testCreateHookEntity_ExternalUserExternalEntity_EntityFetched(self): 79 def testCreateHookEntity_ExternalUserExternalEntity_EntityFetched(self):
79 key = CreateHookModelExample(internal_only=False).put() 80 key = CreateHookModelExample(internal_only=False).put()
80 self.SetCurrentUser('x@foo.com') 81 self.SetCurrentUser('x@foo.com')
81 self.assertEqual(key, key.get().key) 82 self.assertEqual(key, key.get().key)
82 83
83 84
84 if __name__ == '__main__': 85 if __name__ == '__main__':
85 unittest.main() 86 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698