Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2310)

Unified Diff: appengine/findit/waterfall/test/detect_first_failure_pipeline_test.py

Issue 2203643002: [Findit] Use new mock for unittests. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@0708-pipeline-refactor
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/findit/waterfall/test/detect_first_failure_pipeline_test.py
diff --git a/appengine/findit/waterfall/test/detect_first_failure_pipeline_test.py b/appengine/findit/waterfall/test/detect_first_failure_pipeline_test.py
index 0be9af309cbca2f2352b417874b00c830ba4ae1d..108bf325abd5075124ec457a4eb54f2723fcb03b 100644
--- a/appengine/findit/waterfall/test/detect_first_failure_pipeline_test.py
+++ b/appengine/findit/waterfall/test/detect_first_failure_pipeline_test.py
@@ -4,6 +4,7 @@
import datetime
import json
+import mock
import os
import urllib
import zlib
@@ -324,7 +325,8 @@ class DetectFirstFailureTest(wf_testcase.WaterfallTestCase):
self.assertEqual(expected_failed_step, failed_step)
- def testCheckFirstKnownFailureForSwarmingTestsFoundFlaky(self):
+ @mock.patch.object(detect_first_failure_pipeline, 'swarming_util')
+ def testCheckFirstKnownFailureForSwarmingTestsFoundFlaky(self, mock_module):
master_name = 'm'
builder_name = 'b'
build_number = 221
@@ -361,19 +363,10 @@ class DetectFirstFailureTest(wf_testcase.WaterfallTestCase):
step.isolated = True
step.put()
- def MockGetIsolatedDataForFailedBuild(*_):
- return True
- self.mock(
- swarming_util, 'GetIsolatedDataForFailedBuild',
- MockGetIsolatedDataForFailedBuild)
-
- def MockRetrieveShardedTestResultsFromIsolatedServer(*_):
- return json.loads(
- self._GetSwarmingData(
- 'isolated-plain', 'm_b_223_abc_test_flaky.json'))
- self.mock(
- swarming_util, 'RetrieveShardedTestResultsFromIsolatedServer',
- MockRetrieveShardedTestResultsFromIsolatedServer)
+ mock_module.GetIsolatedDataForFailedBuild.return_value = True
+ mock_module.RetrieveShardedTestResultsFromIsolatedServer.return_value = (
+ json.loads(self._GetSwarmingData(
+ 'isolated-plain', 'm_b_223_abc_test_flaky.json')))
pipeline = DetectFirstFailurePipeline()
pipeline._CheckFirstKnownFailureForSwarmingTests(

Powered by Google App Engine
This is Rietveld 408576698