| 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 | 6 |
| 7 from third_party.testing_utils import testing | 7 from third_party.testing_utils import testing |
| 8 | 8 |
| 9 import main | 9 import main |
| 10 from model.record import Record | 10 from model.record import Record |
| 11 from model.cq_stats import CountStats, CQStats, ListStats | 11 from model.cq_stats import CountStats, CQStats, ListStats |
| 12 from shared.config import STATS_START_TIMESTAMP | 12 from shared.config import STATS_START_TIMESTAMP |
| 13 from shared.config import TRYJOBVERIFIER | 13 from shared.config import TRYJOBVERIFIER |
| 14 from shared.utils import minutes_per_day | |
| 15 from handlers import update_stats | 14 from handlers import update_stats |
| 15 from handlers.stats_viewer import minutes_per_day |
| 16 | 16 |
| 17 stats_start = datetime.utcfromtimestamp(STATS_START_TIMESTAMP) | 17 stats_start = datetime.utcfromtimestamp(STATS_START_TIMESTAMP) |
| 18 test_analysis_end = stats_start + timedelta(days=1) | 18 test_analysis_end = stats_start + timedelta(days=1) |
| 19 | 19 |
| 20 class StatsTest(testing.AppengineTestCase): # pragma: no cover | 20 class StatsTest(testing.AppengineTestCase): # pragma: no cover |
| 21 '''Utility class for stats tests that want to load/clear test Record data.''' | 21 '''Utility class for stats tests that want to load/clear test Record data.''' |
| 22 app_module = main.app | 22 app_module = main.app |
| 23 | 23 |
| 24 def add_record(self, hours_from_start, tagged_fields): | 24 def add_record(self, hours_from_start, tagged_fields): |
| 25 tagged_fields.setdefault('project', 'test') | 25 tagged_fields.setdefault('project', 'test') |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 def get_stats(name): | 84 def get_stats(name): |
| 85 cq_stats = CQStats.query(CQStats.begin == stats_start).get() | 85 cq_stats = CQStats.query(CQStats.begin == stats_start).get() |
| 86 for stats in cq_stats.count_stats + cq_stats.list_stats: | 86 for stats in cq_stats.count_stats + cq_stats.list_stats: |
| 87 if stats.name == name: | 87 if stats.name == name: |
| 88 return stats | 88 return stats |
| 89 return None | 89 return None |
| 90 | 90 |
| 91 def hours(n): # pragma: no cover | 91 def hours(n): # pragma: no cover |
| 92 '''Convert hours to seconds.''' | 92 '''Convert hours to seconds.''' |
| 93 return n * 60 * 60 | 93 return n * 60 * 60 |
| OLD | NEW |