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

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

Issue 2521773004: [Culprit-finder] Refactor findit testcase and move it to libs. (Closed)
Patch Set: . Created 4 years 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
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import os
6
7 from testing_utils import testing
8
9 from lib import time_util
10
11
12 class FinditTestCase(testing.AppengineTestCase): # pragma: no cover.
13 # Setup the customized queues.
14 taskqueue_stub_root_path = os.path.join(
15 os.path.dirname(__file__), os.path.pardir)
16
17 def MockPipeline(
18 self, pipeline_class, result, expected_args, expected_kwargs=None):
19 """Mocks a pipeline to return a value and asserts the expected parameters.
20
21 Args:
22 pipeline_class (class): The class of the pipeline to be mocked.
23 result (object): The result to be returned by the pipeline.
24 expected_args (list): The list of positional parameters expected by the
25 pipeline.
26 expected_kwargs (dict): The dict of key-value parameters expected by the
27 pipeline. Default is None.
28 """
29 expected_kwargs = expected_kwargs or {}
30
31 def Mocked_run(_, *args, **kwargs):
32 self.assertEqual(list(args), expected_args)
33 self.assertEqual(kwargs, expected_kwargs)
34 return result
35
36 self.mock(pipeline_class, 'run', Mocked_run)
37
38 def MockUTCNow(self, mocked_utcnow):
39 """Mocks utcnow with the given value for testing."""
40 self.mock(time_util, 'GetUTCNow', lambda: mocked_utcnow)
41
42 def MockUTCNowWithTimezone(self, mocked_utcnow):
43 """Mocks utcnow with the given value for testing."""
44 self.mock(time_util, 'GetUTCNowWithTimezone', lambda: mocked_utcnow)
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/crash/test/crash_testcase.py » ('j') | appengine/findit/libs/testcase.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698