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

Side by Side Diff: appengine/findit/common/findit_testcase.py

Issue 2158533002: [Findit] Use unittest.mock for testing and create a shared method to mock pipeline. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | appengine/findit/waterfall/analyze_build_failure_pipeline.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 os 5 import os
6 6
7 from testing_utils import testing 7 from testing_utils import testing
8 8
9 9
10 class FinditTestCase(testing.AppengineTestCase): 10 class FinditTestCase(testing.AppengineTestCase): # pragma: no cover.
11 # Setup the customized queues. 11 # Setup the customized queues.
12 taskqueue_stub_root_path = os.path.join( 12 taskqueue_stub_root_path = os.path.join(
13 os.path.dirname(__file__), os.path.pardir) 13 os.path.dirname(__file__), os.path.pardir)
14
15 def MockPipeline(
16 self, pipeline_class, result, expected_args, expected_kwargs=None):
17 """ Mocks a pipeline to return a value and asserts the expected parameters.
18
19 Args:
20 pipeline_class (class): The class of the pipeline to be mocked.
21 result (object): The result to be returned by the pipeline.
22 expected_args (list): The list of positional parameters expected by the
23 pipeline.
24 expected_kwargs (dict): The dict of key-value parameters expected by the
25 pipeline. Default is None.
26 """
27 expected_kwargs = expected_kwargs or {}
28
29 def Mocked_run(_, *args, **kwargs):
30 self.assertEqual(list(args), expected_args)
31 self.assertEqual(kwargs, expected_kwargs)
32 return result
33
34 self.mock(pipeline_class, 'run', Mocked_run)
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/waterfall/analyze_build_failure_pipeline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698