Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 from contextlib import contextmanager | 5 from contextlib import contextmanager |
| 6 import collections | 6 import collections |
| 7 import time | 7 import time |
| 8 | 8 |
| 9 # appengine sdk is supposed to be on the path. | 9 # appengine sdk is supposed to be on the path. |
| 10 import dev_appserver | 10 import dev_appserver |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 | 21 |
| 22 | 22 |
| 23 class AppengineTestCase(auto_stub.TestCase): # pragma: no cover | 23 class AppengineTestCase(auto_stub.TestCase): # pragma: no cover |
| 24 """Base class for Appengine test cases. | 24 """Base class for Appengine test cases. |
| 25 | 25 |
| 26 Must set app_module to use self.test_app. | 26 Must set app_module to use self.test_app. |
| 27 """ | 27 """ |
| 28 | 28 |
| 29 # To be set in tests that wants to use test_app | 29 # To be set in tests that wants to use test_app |
| 30 app_module = None | 30 app_module = None |
| 31 # Datastore consistency policy. | |
| 32 consistency_policy = None | |
|
Vadim Sh.
2015/04/16 00:12:21
hm.. can you please commit it in a separate CL (ve
nodir
2015/04/16 00:36:20
not needed anymore, since xg transactions are not
| |
| 31 | 33 |
| 32 def setUp(self): | 34 def setUp(self): |
| 33 super(AppengineTestCase, self).setUp() | 35 super(AppengineTestCase, self).setUp() |
| 34 self.testbed = testbed.Testbed() | 36 self.testbed = testbed.Testbed() |
| 35 # needed because endpoints expects a . in this value | 37 # needed because endpoints expects a . in this value |
| 36 self.testbed.setup_env(current_version_id='testbed.version') | 38 self.testbed.setup_env(current_version_id='testbed.version') |
| 37 self.testbed.activate() | 39 self.testbed.activate() |
| 38 # Can't use init_all_stubs() because PIL isn't in wheel. | 40 # Can't use init_all_stubs() because PIL isn't in wheel. |
| 39 self.testbed.init_app_identity_stub() | 41 self.testbed.init_app_identity_stub() |
| 40 self.testbed.init_blobstore_stub() | 42 self.testbed.init_blobstore_stub() |
| 41 self.testbed.init_capability_stub() | 43 self.testbed.init_capability_stub() |
| 42 self.testbed.init_channel_stub() | 44 self.testbed.init_channel_stub() |
| 43 self.testbed.init_datastore_v3_stub() | 45 self.testbed.init_datastore_v3_stub( |
| 46 consistency_policy=self.consistency_policy) | |
| 44 self.testbed.init_files_stub() | 47 self.testbed.init_files_stub() |
| 45 self.testbed.init_logservice_stub() | 48 self.testbed.init_logservice_stub() |
| 46 self.testbed.init_mail_stub() | 49 self.testbed.init_mail_stub() |
| 47 self.testbed.init_memcache_stub() | 50 self.testbed.init_memcache_stub() |
| 48 self.testbed.init_taskqueue_stub() | 51 self.testbed.init_taskqueue_stub() |
| 49 self.testbed.init_urlfetch_stub() | 52 self.testbed.init_urlfetch_stub() |
| 50 self.testbed.init_user_stub() | 53 self.testbed.init_user_stub() |
| 51 self.testbed.init_xmpp_stub() | 54 self.testbed.init_xmpp_stub() |
| 52 # Test app is lazily initialized on a first use from app_module. | 55 # Test app is lazily initialized on a first use from app_module. |
| 53 self._test_app = None | 56 self._test_app = None |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 @contextmanager | 183 @contextmanager |
| 181 def call_should_fail(self, _status): | 184 def call_should_fail(self, _status): |
| 182 """Asserts that Endpoints call inside the guarded region of code fails.""" | 185 """Asserts that Endpoints call inside the guarded region of code fails.""" |
| 183 # This should be a call_api(..., status=<something>). Unfortunately, | 186 # This should be a call_api(..., status=<something>). Unfortunately, |
| 184 # Cloud Endpoints doesn't interact with webtest properly. See | 187 # Cloud Endpoints doesn't interact with webtest properly. See |
| 185 # https://code.google.com/p/googleappengine/issues/detail?id=10544 and | 188 # https://code.google.com/p/googleappengine/issues/detail?id=10544 and |
| 186 # http://stackoverflow.com/questions/24219654/content-length-error-in- | 189 # http://stackoverflow.com/questions/24219654/content-length-error-in- |
| 187 # google-cloud-endpoints-testing | 190 # google-cloud-endpoints-testing |
| 188 with self.assertRaises(AssertionError): | 191 with self.assertRaises(AssertionError): |
| 189 yield | 192 yield |
| OLD | NEW |