| 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 datetime import datetime | 5 from datetime import datetime |
| 6 import json | 6 import json |
| 7 import os | 7 import os |
| 8 import sys | |
| 9 | |
| 10 # App Engine source file imports must be relative to their app's root. | |
| 11 sys.path.append(os.path.dirname(os.path.dirname(__file__))) | |
| 12 | 8 |
| 13 from appengine.utils import testing | 9 from appengine.utils import testing |
| 14 from appengine.chromium_cq_status import main | 10 |
| 15 from appengine.chromium_cq_status.model.record import Record | 11 from appengine.path_mangler_hack import PathMangler |
| 12 with PathMangler(os.path.dirname(os.path.dirname(__file__))): |
| 13 from appengine.chromium_cq_status import main |
| 14 from appengine.chromium_cq_status.model.record import Record |
| 16 | 15 |
| 17 class TestQuery(testing.AppengineTestCase): | 16 class TestQuery(testing.AppengineTestCase): |
| 18 app_module = main.app | 17 app_module = main.app |
| 19 | 18 |
| 20 def test_query_headers(self): | 19 def test_query_headers(self): |
| 21 _clear_records() | 20 _clear_records() |
| 22 response = self.test_app.get('/query') | 21 response = self.test_app.get('/query') |
| 23 self.assertEquals(response.headers['Access-Control-Allow-Origin'], '*') | 22 self.assertEquals(response.headers['Access-Control-Allow-Origin'], '*') |
| 24 | 23 |
| 25 def test_query_empty(self): | 24 def test_query_empty(self): |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 preserve_cursor=False, preserve_timestamp=False): # pragma: no cover | 362 preserve_cursor=False, preserve_timestamp=False): # pragma: no cover |
| 364 packet = json.loads(response.body) | 363 packet = json.loads(response.body) |
| 365 if not preserve_cursor: | 364 if not preserve_cursor: |
| 366 del packet['cursor'] | 365 del packet['cursor'] |
| 367 packet['results'].sort() | 366 packet['results'].sort() |
| 368 for result in packet['results']: | 367 for result in packet['results']: |
| 369 result['tags'].sort() | 368 result['tags'].sort() |
| 370 if not preserve_timestamp: | 369 if not preserve_timestamp: |
| 371 del result['timestamp'] | 370 del result['timestamp'] |
| 372 return packet | 371 return packet |
| OLD | NEW |