| 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, timedelta | 5 from datetime import datetime, timedelta |
| 6 import json | 6 import json |
| 7 | 7 |
| 8 from google.appengine.api import memcache | 8 from google.appengine.api import memcache |
| 9 | 9 |
| 10 from third_party.testing_utils import testing | 10 from third_party.testing_utils import testing |
| 11 | 11 |
| 12 import highend | 12 import highend |
| 13 from model.cq_stats import ( | 13 from model.cq_stats import ( |
| 14 CountStats, | 14 CountStats, |
| 15 CQStats, | 15 CQStats, |
| 16 ListStats, | 16 ListStats, |
| 17 ) | 17 ) |
| 18 from shared.config import LAST_CQ_STATS_CHANGE_KEY | 18 from shared.config import LAST_CQ_STATS_CHANGE_KEY |
| 19 from shared.utils import minutes_per_day, timestamp_now | 19 from shared.utils import timestamp_now |
| 20 |
| 21 from handlers.stats_viewer import minutes_per_day |
| 20 | 22 |
| 21 class TestStatsQuery(testing.AppengineTestCase): | 23 class TestStatsQuery(testing.AppengineTestCase): |
| 22 app_module = highend.app | 24 app_module = highend.app |
| 23 maxDiff = None | 25 maxDiff = None |
| 24 | 26 |
| 25 def test_query_headers(self): | 27 def test_query_headers(self): |
| 26 _clear_stats() | 28 _clear_stats() |
| 27 response = self.test_app.get('/stats/query') | 29 response = self.test_app.get('/stats/query') |
| 28 self.assertEquals(response.headers['Access-Control-Allow-Origin'], '*') | 30 self.assertEquals(response.headers['Access-Control-Allow-Origin'], '*') |
| 29 | 31 |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 cq_stats.put() | 380 cq_stats.put() |
| 379 return cq_stats | 381 return cq_stats |
| 380 | 382 |
| 381 def _parse_body(response, preserve_cursor=False): # pragma: no cover | 383 def _parse_body(response, preserve_cursor=False): # pragma: no cover |
| 382 packet = json.loads(response.body) | 384 packet = json.loads(response.body) |
| 383 if not preserve_cursor: | 385 if not preserve_cursor: |
| 384 del packet['cursor'] | 386 del packet['cursor'] |
| 385 for cq_stats in packet['results']: | 387 for cq_stats in packet['results']: |
| 386 del cq_stats['key'] | 388 del cq_stats['key'] |
| 387 return packet | 389 return packet |
| OLD | NEW |