| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 import json | 6 import json |
| 7 import mock | 7 import mock |
| 8 import urllib2 | 8 import urllib2 |
| 9 | 9 |
| 10 from google.appengine.datastore import datastore_stub_util | 10 from google.appengine.datastore import datastore_stub_util |
| 11 from google.appengine.ext import ndb | 11 from google.appengine.ext import ndb |
| 12 | 12 |
| 13 from handlers.flake_issues import ProcessIssue, CreateFlakyRun | 13 from handlers.flake_issues import ProcessIssue, CreateFlakyRun |
| 14 import main | 14 import main |
| 15 from infra_libs import ts_mon |
| 15 from model.flake import Flake, FlakyRun, FlakeOccurrence | 16 from model.flake import Flake, FlakyRun, FlakeOccurrence |
| 16 from model.build_run import PatchsetBuilderRuns, BuildRun | 17 from model.build_run import PatchsetBuilderRuns, BuildRun |
| 17 from testing_utils import testing | 18 from testing_utils import testing |
| 18 from time_functions.testing import mock_datetime_utc | 19 from time_functions.testing import mock_datetime_utc |
| 19 | 20 |
| 20 | 21 |
| 21 TEST_TEST_RESULTS_REPLY = json.dumps({ | 22 TEST_TEST_RESULTS_REPLY = json.dumps({ |
| 22 'tests': { | 23 'tests': { |
| 23 'test1': { | 24 'test1': { |
| 24 'expected': 'PASS', | 25 'expected': 'PASS', |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 137 |
| 137 # This is needed to be able to test handlers using cross-group transactions. | 138 # This is needed to be able to test handlers using cross-group transactions. |
| 138 datastore_stub_consistency_policy = ( | 139 datastore_stub_consistency_policy = ( |
| 139 datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)) | 140 datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)) |
| 140 | 141 |
| 141 # Needed to read queues from queue.yaml in the root of the app. | 142 # Needed to read queues from queue.yaml in the root of the app. |
| 142 taskqueue_stub_root_path = '.' | 143 taskqueue_stub_root_path = '.' |
| 143 | 144 |
| 144 def setUp(self): | 145 def setUp(self): |
| 145 super(FlakeIssuesTestCase, self).setUp() | 146 super(FlakeIssuesTestCase, self).setUp() |
| 147 ts_mon.reset_for_unittest(disable=True) |
| 146 self.mock_api = MockIssueTrackerAPI() | 148 self.mock_api = MockIssueTrackerAPI() |
| 147 self.patchers = [ | 149 self.patchers = [ |
| 148 mock.patch('issue_tracker.issue_tracker_api.IssueTrackerAPI', | 150 mock.patch('issue_tracker.issue_tracker_api.IssueTrackerAPI', |
| 149 lambda *args, **kwargs: self.mock_api), | 151 lambda *args, **kwargs: self.mock_api), |
| 150 mock.patch('issue_tracker.issue.Issue', MockIssue), | 152 mock.patch('issue_tracker.issue.Issue', MockIssue), |
| 151 ] | 153 ] |
| 152 for patcher in self.patchers: | 154 for patcher in self.patchers: |
| 153 patcher.start() | 155 patcher.start() |
| 154 | 156 |
| 155 def tearDown(self): | 157 def tearDown(self): |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 | 742 |
| 741 for flake in flakes: | 743 for flake in flakes: |
| 742 self.assertEqual(flake.occurrences, [flaky_run.key]) | 744 self.assertEqual(flake.occurrences, [flaky_run.key]) |
| 743 | 745 |
| 744 def test_flattens_tests_correctly(self): | 746 def test_flattens_tests_correctly(self): |
| 745 passed, failed, skipped = CreateFlakyRun._flatten_tests( | 747 passed, failed, skipped = CreateFlakyRun._flatten_tests( |
| 746 json.loads(TEST_TEST_RESULTS_REPLY)['tests'], '/') | 748 json.loads(TEST_TEST_RESULTS_REPLY)['tests'], '/') |
| 747 self.assertEqual(set(passed), set(['test1'])) | 749 self.assertEqual(set(passed), set(['test1'])) |
| 748 self.assertEqual(set(failed), set(['test2/a', 'test2/d'])) | 750 self.assertEqual(set(failed), set(['test2/a', 'test2/d'])) |
| 749 self.assertEqual(set(skipped), set(['test2/b'])) | 751 self.assertEqual(set(skipped), set(['test2/b'])) |
| OLD | NEW |