| # Copyright 2020 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| from recipe_engine import recipe_test_api |
| |
| |
| class TreeStatusTestApi(recipe_test_api.RecipeTestApi): |
| def get(self, **kwargs): |
| step_name = kwargs.pop("step_name", "get current tree status") |
| return self.step_data(step_name, self.status_step_data(**kwargs)) |
| |
| def status_step_data(self, state="OPEN", key=12345, tree_name=None): |
| if tree_name: |
| return self.m.json.output_stream( |
| { |
| "generalState": state, |
| "createTime": "2020-12-01T23:07:11.234Z", |
| "name": f"trees/{tree_name}/status/{key}", |
| "message": f"Tree is {state}", |
| } |
| ) |
| return self.m.json.output_stream( |
| { |
| "general_state": state.lower(), |
| "date": "2020-12-01 23:07:06.234", |
| "username": "user@example.com", |
| "key": key, |
| "message": f"Tree is {state}", |
| } |
| ) |