| # 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.recipe_api import Property |
| |
| DEPS = [ |
| "fuchsia/tree_status", |
| "recipe_engine/properties", |
| ] |
| |
| HOSTNAME = "fuchsia-stem-status.appspot.com" |
| ADMIN_HOSTNAME = "fuchsia-status-adm.googleplex.com" |
| |
| PROPERTIES = { |
| "check_for_collisions": Property(default=False), |
| "tree_name": Property(default=None), |
| } |
| |
| |
| def RunSteps(api, check_for_collisions, tree_name): |
| status = api.tree_status.get(hostname=HOSTNAME, tree_name=tree_name) |
| status.open # pylint: disable=pointless-statement |
| |
| last_status = None |
| if check_for_collisions: |
| last_status = status |
| |
| api.tree_status.update( |
| hostname=HOSTNAME, |
| admin_hostname=ADMIN_HOSTNAME, |
| message="Tree is closed.", |
| last_status=last_status, |
| state="CLOSED", |
| issuetracker_id="1337", |
| tree_name=tree_name, |
| ) |
| |
| |
| def GenTests(api): |
| yield api.test("closed") + api.properties( |
| tree_name="fuchsia" |
| ) + api.tree_status.get(state="CLOSED", tree_name="fuchsia") |
| yield ( |
| api.test("collision", status="FAILURE") |
| + api.properties(check_for_collisions=True) |
| + api.tree_status.get(key=123) |
| + api.tree_status.get(key=124, step_name="check for tree status collision") |
| ) |