| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 import datetime | 5 import datetime |
| 6 | 6 |
| 7 from testing_utils import testing | 7 from testing_utils import testing |
| 8 | 8 |
| 9 from handlers import all_flake_occurrences | 9 from handlers import all_flake_occurrences |
| 10 import main | 10 import main |
| 11 from model.flake import Flake, FlakyRun, FlakeOccurrence | 11 from model.flake import Flake, FlakyRun, FlakeOccurrence |
| 12 from model.build_run import PatchsetBuilderRuns, BuildRun | 12 from model.build_run import PatchsetBuilderRuns, BuildRun |
| 13 | 13 |
| 14 | 14 |
| 15 class TestAllFlakeOccurrences(testing.AppengineTestCase): | 15 class TestAllFlakeOccurrences(testing.AppengineTestCase): |
| 16 app_module = main.app | 16 app_module = main.app |
| 17 | 17 |
| 18 def _create_flake(self): | 18 def _create_flake(self): |
| 19 tf = datetime.datetime(2016, 06, 06, 10, 20, 30) | 19 tf = datetime.datetime(2016, 8, 6, 10, 20, 30) |
| 20 ts = tf - datetime.timedelta(hours=1) | 20 ts = tf - datetime.timedelta(hours=1) |
| 21 tf2 = tf - datetime.timedelta(days=5) | 21 tf2 = tf - datetime.timedelta(days=5) |
| 22 ts2 = tf2 - datetime.timedelta(hours=1) | 22 ts2 = tf2 - datetime.timedelta(hours=1) |
| 23 p = PatchsetBuilderRuns(issue=123456, patchset=1, master='tryserver.test', | 23 p = PatchsetBuilderRuns(issue=123456, patchset=1, master='tryserver.test', |
| 24 builder='test-builder').put() | 24 builder='test-builder').put() |
| 25 br_f0 = BuildRun(parent=p, buildnumber=0, result=2, time_started=ts2, | 25 br_f0 = BuildRun(parent=p, buildnumber=0, result=2, time_started=ts2, |
| 26 time_finished=tf2).put() | 26 time_finished=tf2).put() |
| 27 br_f1 = BuildRun(parent=p, buildnumber=1, result=2, time_started=ts, | 27 br_f1 = BuildRun(parent=p, buildnumber=1, result=2, time_started=ts, |
| 28 time_finished=tf).put() | 28 time_finished=tf).put() |
| 29 br_s1 = BuildRun(parent=p, buildnumber=2, result=0, time_started=ts, | 29 br_s1 = BuildRun(parent=p, buildnumber=2, result=0, time_started=ts, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 flake_key = self._create_flake().put() | 95 flake_key = self._create_flake().put() |
| 96 self.test_app.get('/all_flake_occurrences?key=%s.' % flake_key.urlsafe()) | 96 self.test_app.get('/all_flake_occurrences?key=%s.' % flake_key.urlsafe()) |
| 97 | 97 |
| 98 def test_missing_key(self): | 98 def test_missing_key(self): |
| 99 response = self.test_app.get('/all_flake_occurrences?key=', status=400) | 99 response = self.test_app.get('/all_flake_occurrences?key=', status=400) |
| 100 self.assertEqual(response.status, '400 Flake ID is not specified') | 100 self.assertEqual(response.status, '400 Flake ID is not specified') |
| 101 | 101 |
| 102 def test_all_flake_occurrences_key_with_invalid_key(self): | 102 def test_all_flake_occurrences_key_with_invalid_key(self): |
| 103 response = self.test_app.get('/all_flake_occurrences?key=foo', status=404) | 103 response = self.test_app.get('/all_flake_occurrences?key=foo', status=404) |
| 104 self.assertEqual(response.status, '404 Failed to find flake with id "foo"') | 104 self.assertEqual(response.status, '404 Failed to find flake with id "foo"') |
| OLD | NEW |