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

Side by Side Diff: scripts/slave/recipe_modules/recipe_autoroller/test_api.py

Issue 2214303003: Revert of Removing old recipe code (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: 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 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 json
6
7 from recipe_engine import recipe_test_api
8
9
10 class RecipeAutorollerTestApi(recipe_test_api.RecipeTestApi):
11 def roll_data(self, project, success=True, trivial=True, empty=False):
12 """Returns mock roll data for |project|."""
13 if empty:
14 success = False
15
16 ret = self.empty_test_data()
17
18 picked_roll_details = {
19 'commit_infos': {
20 'recipe_engine': [
21 {
22 'author': 'foo@chromium.org',
23 'message': '\n'.join([
24 'some commit message',
25 'R=bar@chromium.org,baz@chromium.org,invalid1,invalid2@chromium',
26 'BUG=123,456',
27 ]),
28 'revision': '123abc',
29 },
30 ],
31 },
32 'spec': 'api_version: 1\netc: "etc"\n',
33 }
34
35 roll_result = {
36 'success': success,
37 'trivial': trivial if success else None,
38 'picked_roll_details': picked_roll_details if success else None,
39 'rejected_candidates_details': [],
40 }
41 if empty:
42 roll_result['roll_details'] = []
43 else:
44 roll_result['roll_details'] = [picked_roll_details]
45 if not success:
46 roll_result['rejected_candidates_details'].append({
47 'spec': 'some_spec',
48 'commit_infos': {
49 },
50 })
51
52 ret += self.step_data('%s.roll' % project, self.m.json.output(roll_result))
53 return ret
54
55 def new_upload(self, project):
56 return self.step_data('%s.gsutil cat' % project,
57 self.m.raw_io.stream_output('', stream='stdout'),
58 self.m.raw_io.stream_output('Error: No URLs matched ...',
59 stream='stderr'),
60 retcode=1)
61
62 def previously_uploaded(self, project):
63 return self.step_data('%s.gsutil cat' % project,
64 self.m.raw_io.stream_output(json.dumps(
65 {
66 'issue': '123456789',
67 'issue_url': 'https://codereview.chromium.org/123456789',
68 'diff_digest': 'afe53a0e969fd0b2a6b5c5f89724d0c6'
69 }),
70 stream='stdout'),
71 self.m.raw_io.stream_output('', stream='stderr'))
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/recipe_autoroller/api.py ('k') | scripts/slave/recipe_modules/recipe_tryjob/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698