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

Side by Side Diff: appengine/monorail/services/test/client_config_svc_test.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 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
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is govered by a BSD-style
3 # license that can be found in the LICENSE file or at
4 # https://developers.google.com/open-source/licenses/bsd
5
6 """Tests for the client config service."""
7
8 import unittest
9
10 from services import client_config_svc
11
12
13 class ClientConfigServiceTest(unittest.TestCase):
14
15 def setUp(self):
16 self.client_config_svc = client_config_svc.GetClientConfigSvc()
17 self.client_email = '123456789@developer.gserviceaccount.com'
18 self.client_id = '123456789.apps.googleusercontent.com'
19
20 def testGetDisplayNames(self):
21 display_names_map = self.client_config_svc.GetDisplayNames()
22 self.assertIn(self.client_email, display_names_map)
23 self.assertEquals('johndoe@example.com',
24 display_names_map[self.client_email])
25
26 def testGetClientIDEmails(self):
27 auth_client_ids, auth_emails = self.client_config_svc.GetClientIDEmails()
28 self.assertIn(self.client_id, auth_client_ids)
29 self.assertIn(self.client_email, auth_emails)
30
31 def testForceLoad(self):
32 # First time it will always read the config
33 self.client_config_svc.load_time = 10000
34 self.client_config_svc.GetConfigs(use_cache=True)
35 self.assertNotEquals(10000, self.client_config_svc.load_time)
36
37 # use_cache is false and it will read the config
38 self.client_config_svc.load_time = 10000
39 self.client_config_svc.GetConfigs(use_cache=False, cur_time=11000)
40 self.assertNotEquals(10000, self.client_config_svc.load_time)
41
42 # Cache expires after 3600 sec and it will read the config
43 self.client_config_svc.load_time = 10000
44 self.client_config_svc.GetConfigs(use_cache=True, cur_time=20000)
45 self.assertNotEquals(10000, self.client_config_svc.load_time)
46
47 # otherwise it should just use the cache
48 self.client_config_svc.load_time = 10000
49 self.client_config_svc.GetConfigs(use_cache=True, cur_time=11000)
50 self.assertEquals(10000, self.client_config_svc.load_time)
OLDNEW
« no previous file with comments | « appengine/monorail/services/test/caches_test.py ('k') | appengine/monorail/services/test/config_svc_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698