| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 datetime | 5 import datetime |
| 6 import mock | 6 import mock |
| 7 | 7 |
| 8 from google.appengine.datastore import datastore_stub_util | 8 from google.appengine.datastore import datastore_stub_util |
| 9 | 9 |
| 10 import main # Fiddles sys.path so must come first. | 10 import main # Fiddles sys.path so must come first. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 datastore_stub_consistency_policy = ( | 23 datastore_stub_consistency_policy = ( |
| 24 datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)) | 24 datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)) |
| 25 | 25 |
| 26 def setUp(self): | 26 def setUp(self): |
| 27 super(FindItAPITestCase, self).setUp() | 27 super(FindItAPITestCase, self).setUp() |
| 28 gae_ts_mon.reset_for_unittest(disable=True) | 28 gae_ts_mon.reset_for_unittest(disable=True) |
| 29 self.maxDiff = None | 29 self.maxDiff = None |
| 30 self.client = mock.Mock() | 30 self.client = mock.Mock() |
| 31 self.build_client = mock.Mock(return_value=self.client) | 31 self.build_client = mock.Mock(return_value=self.client) |
| 32 self.patchers = [ | 32 self.patchers = [ |
| 33 mock.patch('endpoints.endpoints.build_client', self.build_client), | 33 mock.patch( |
| 34 mock.patch('endpoints.endpoints.retry_request', mock.Mock()), | 34 'endpoints_client.endpoints.build_client', self.build_client), |
| 35 mock.patch('endpoints_client.endpoints.retry_request', mock.Mock()), |
| 35 ] | 36 ] |
| 36 for patcher in self.patchers: | 37 for patcher in self.patchers: |
| 37 patcher.start() | 38 patcher.start() |
| 38 | 39 |
| 39 def tearDown(self): | 40 def tearDown(self): |
| 40 super(FindItAPITestCase, self).tearDown() | 41 super(FindItAPITestCase, self).tearDown() |
| 41 for patcher in self.patchers: | 42 for patcher in self.patchers: |
| 42 patcher.stop() | 43 patcher.stop() |
| 43 | 44 |
| 44 @staticmethod | 45 @staticmethod |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 'appspot.com/_ah/api/discovery/v1/apis/{api}/{apiVersion}/rest') | 113 'appspot.com/_ah/api/discovery/v1/apis/{api}/{apiVersion}/rest') |
| 113 | 114 |
| 114 def test_uses_prod_instance_by_default(self): | 115 def test_uses_prod_instance_by_default(self): |
| 115 findit.FindItAPI() | 116 findit.FindItAPI() |
| 116 self.assertEquals(self.build_client.call_count, 1) | 117 self.assertEquals(self.build_client.call_count, 1) |
| 117 self.assertEquals(self.build_client.call_args[0][0], 'findit') | 118 self.assertEquals(self.build_client.call_args[0][0], 'findit') |
| 118 self.assertEquals(self.build_client.call_args[0][1], 'v1') | 119 self.assertEquals(self.build_client.call_args[0][1], 'v1') |
| 119 self.assertEquals( | 120 self.assertEquals( |
| 120 self.build_client.call_args[0][2], 'https://findit-for-me.appspot.com/' | 121 self.build_client.call_args[0][2], 'https://findit-for-me.appspot.com/' |
| 121 '_ah/api/discovery/v1/apis/{api}/{apiVersion}/rest') | 122 '_ah/api/discovery/v1/apis/{api}/{apiVersion}/rest') |
| OLD | NEW |