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

Side by Side Diff: recipe_modules/url/test_api.py

Issue 2868333004: Add URL recipe module from "depot_tools". (Closed)
Patch Set: Update comments with exceptions Created 3 years, 7 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 | « recipe_modules/url/resources/pycurl.py ('k') | recipe_modules/url/tests/join.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2017 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file.
4
5 import httplib
6
7 from recipe_engine import recipe_test_api
8
9 class UrlTestApi(recipe_test_api.RecipeTestApi): # pragma: no cover
10
11 def _response(self, step_name, data, size, status_code, error_body):
12 step_data = [
13 self.m.json.output({
14 'status_code': status_code,
15 'success': status_code in (httplib.OK, httplib.NO_CONTENT),
16 'size': size,
17 'error_body': error_body,
18 }, name='status_json'),
19 ]
20 if data:
21 step_data.append(data)
22 return self.step_data(step_name, *step_data)
23
24 def error(self, step_name, status_code, body=None):
25 body = body or 'HTTP Error (%d)' % (status_code,)
26 return self._response(
27 step_name,
28 None,
29 len(body),
30 status_code,
31 body)
32
33 def text(self, step_name, v):
34 return self._response(
35 step_name,
36 self.m.raw_io.output_text(v, name='output'),
37 len(v),
38 200,
39 None)
40
41 def json(self, step_name, obj):
42 return self._response(
43 step_name,
44 self.m.json.output(obj, name='output'),
45 len(self.m.json.dumps(obj)),
46 200,
47 None)
OLDNEW
« no previous file with comments | « recipe_modules/url/resources/pycurl.py ('k') | recipe_modules/url/tests/join.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698