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

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

Issue 2868333004: Add URL recipe module from "depot_tools". (Closed)
Patch Set: response api object 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
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
10 class UrlTestApi(recipe_test_api.RecipeTestApi): # pragma: no cover
11
12 def _response(self, step_name, data, status_code):
13 step_data = [
14 self.m.json.output({
15 'status_code': status_code,
16 'success': status_code in (httplib.OK, httplib.NO_CONTENT),
17 }, name='status_json'),
18 ]
19 if data:
20 step_data.append(data)
21 return self.step_data(step_name, *step_data)
22
23 def error(self, step_name, status_code):
24 return self._response(
25 step_name,
26 None,
27 status_code)
28
29 def text(self, step_name, v):
30 return self._response(
31 step_name,
32 self.m.raw_io.output_text(v, name='output'),
33 200)
34
35 def json(self, step_name, obj):
36 return self._response(
37 step_name,
38 self.m.json.output(obj, name='output'),
39 200)
OLDNEW
« recipe_modules/url/resources/pycurl.py ('K') | « recipe_modules/url/resources/pycurl.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698