OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Swarming Authors. All rights reserved. | 2 # Copyright 2014 The Swarming Authors. All rights reserved. |
3 # Use of this source code is governed by the Apache v2.0 license that can be | 3 # Use of this source code is governed by the Apache v2.0 license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Smoke test for Cloud Endpoints support in auth component. | 6 """Smoke test for Cloud Endpoints support in auth component. |
7 | 7 |
8 It launches app via dev_appserver and queries a bunch of cloud endpoints | 8 It launches app via dev_appserver and queries a bunch of cloud endpoints |
9 methods. | 9 methods. |
10 """ | 10 """ |
11 | 11 |
12 import unittest | 12 import unittest |
13 import os | 13 import os |
| 14 import sys |
14 | 15 |
| 16 THIS_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 17 TEST_APP_DIR = os.path.join(THIS_DIR, 'test_endpoints_app') |
| 18 CLIENT_DIR = os.path.join( |
| 19 os.path.dirname(os.path.dirname(os.path.dirname(THIS_DIR))), 'client') |
| 20 sys.path.insert(0, CLIENT_DIR) |
| 21 |
| 22 from third_party.depot_tools import fix_encoding |
15 from tool_support import gae_sdk_utils | 23 from tool_support import gae_sdk_utils |
16 from tool_support import local_app | 24 from tool_support import local_app |
17 | 25 |
18 | 26 |
19 THIS_DIR = os.path.dirname(os.path.abspath(__file__)) | |
20 TEST_APP_DIR = os.path.join(THIS_DIR, 'test_endpoints_app') | |
21 | |
22 | |
23 class CloudEndpointsSmokeTest(unittest.TestCase): | 27 class CloudEndpointsSmokeTest(unittest.TestCase): |
24 def setUp(self): | 28 def setUp(self): |
25 super(CloudEndpointsSmokeTest, self).setUp() | 29 super(CloudEndpointsSmokeTest, self).setUp() |
26 self.app = local_app.LocalApplication(TEST_APP_DIR, 9700) | 30 self.app = local_app.LocalApplication(TEST_APP_DIR, 9700) |
27 self.app.start() | 31 self.app.start() |
28 self.app.ensure_serving() | 32 self.app.ensure_serving() |
29 | 33 |
30 def tearDown(self): | 34 def tearDown(self): |
31 try: | 35 try: |
32 self.app.stop() | 36 self.app.stop() |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 self.assertTrue(token) | 89 self.assertTrue(token) |
86 | 90 |
87 # Verify it is usable. | 91 # Verify it is usable. |
88 response = self.app.client.json_request( | 92 response = self.app.client.json_request( |
89 '/_ah/api/testing_service/v1/who', headers={'X-Host-Token-V1': token}) | 93 '/_ah/api/testing_service/v1/who', headers={'X-Host-Token-V1': token}) |
90 self.assertEqual(200, response.http_code) | 94 self.assertEqual(200, response.http_code) |
91 self.assertEqual('host-name', response.body.get('host')) | 95 self.assertEqual('host-name', response.body.get('host')) |
92 | 96 |
93 | 97 |
94 if __name__ == '__main__': | 98 if __name__ == '__main__': |
| 99 fix_encoding.fix_encoding() |
95 gae_sdk_utils.setup_gae_env() | 100 gae_sdk_utils.setup_gae_env() |
96 unittest.main() | 101 unittest.main() |
OLD | NEW |