OLD | NEW |
| (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')) | |
OLD | NEW |