| # Copyright 2020 The Pigweed Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| # use this file except in compliance with the License. You may obtain a copy of |
| # the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations under |
| # the License. |
| """Test of label functionality of roll_util.""" |
| |
| from __future__ import annotations |
| |
| from typing import TYPE_CHECKING |
| |
| if TYPE_CHECKING: # pragma: no cover |
| from typing import Generator |
| from recipe_engine import recipe_test_api |
| |
| DEPS = [ |
| 'pigweed/roll_util', |
| 'recipe_engine/step', |
| ] |
| |
| |
| def RunSteps(api): |
| if api.roll_util.labels_to_set: |
| with api.step.nest('labels_to_set') as pres: |
| pres.step_summary_text = repr(api.roll_util.labels_to_set) |
| if api.roll_util.labels_to_wait_on: |
| with api.step.nest('labels_to_wait_on') as pres: |
| pres.step_summary_text = repr(api.roll_util.labels_to_wait_on) |
| |
| assert api.roll_util.test_api.format_prefix('foo') == 'foo.' |
| assert ( |
| api.roll_util.normalize_remote('../foo', 'sso://host/bar') |
| == 'https://host.googlesource.com/foo' |
| ) |
| |
| |
| def GenTests(api) -> Generator[recipe_test_api.TestData, None, None]: |
| yield api.test( |
| 'labels', |
| api.roll_util.properties( |
| labels_to_set={'Trigger': 1, 'Foo': 123}, |
| labels_to_wait_on=['Verified', 'Good'], |
| ), |
| ) |