OLD | NEW |
(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) |
OLD | NEW |