Index: recipe_modules/json/test_api.py |
diff --git a/recipe_modules/json/test_api.py b/recipe_modules/json/test_api.py |
index 22b9ffbf993e5b1cd337a092efa2dd8044c1b223..e260238a82aaaac0d8235923dcc271c1fd8fc996 100644 |
--- a/recipe_modules/json/test_api.py |
+++ b/recipe_modules/json/test_api.py |
@@ -10,8 +10,22 @@ class JsonTestApi(recipe_test_api.RecipeTestApi): |
@recipe_test_api.placeholder_step_data |
@staticmethod |
def output(data, retcode=None, name=None): |
+ """Supplies placeholder data for a json.output. `data` should be a jsonish |
+ python object (e.g. dict, list, str, bool, int, etc). It will be dumped out |
+ with json.dumps and the step will be observed to return that dumped value. |
+ """ |
return json.dumps(data), retcode, name |
+ def invalid(self, raw_data_str, retcode=None, name=None): |
+ """Can be used to supply data for a json.output, except that it takes a raw |
+ string rather than a json object.""" |
+ ret = recipe_test_api.StepTestData() |
+ ret.retcode=retcode |
+ placeholder_data = recipe_test_api.PlaceholderTestData( |
+ data=raw_data_str, name=name) |
+ ret.placeholder_data[(self._module.NAME, 'output', name)] = placeholder_data |
+ return ret |
+ |
def output_stream(self, data, stream='stdout', retcode=None, name=None): |
assert stream in ('stdout', 'stderr') |
ret = recipe_test_api.StepTestData() |