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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: recipe_modules/url/test_api.py
diff --git a/recipe_modules/url/test_api.py b/recipe_modules/url/test_api.py
new file mode 100644
index 0000000000000000000000000000000000000000..d4a66c51c00848094d9561ade8a40cdbc0f3eee9
--- /dev/null
+++ b/recipe_modules/url/test_api.py
@@ -0,0 +1,39 @@
+# Copyright 2017 The LUCI Authors. All rights reserved.
+# Use of this source code is governed under the Apache License, Version 2.0
+# that can be found in the LICENSE file.
+
+import httplib
+
+from recipe_engine import recipe_test_api
+
+
+class UrlTestApi(recipe_test_api.RecipeTestApi): # pragma: no cover
+
+ def _response(self, step_name, data, status_code):
+ step_data = [
+ self.m.json.output({
+ 'status_code': status_code,
+ 'success': status_code in (httplib.OK, httplib.NO_CONTENT),
+ }, name='status_json'),
+ ]
+ if data:
+ step_data.append(data)
+ return self.step_data(step_name, *step_data)
+
+ def error(self, step_name, status_code):
+ return self._response(
+ step_name,
+ None,
+ status_code)
+
+ def text(self, step_name, v):
+ return self._response(
+ step_name,
+ self.m.raw_io.output_text(v, name='output'),
+ 200)
+
+ def json(self, step_name, obj):
+ return self._response(
+ step_name,
+ self.m.json.output(obj, name='output'),
+ 200)
« 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