Skip to content

Commit 017d785

Browse files
committed
refactor(black): apply black
1 parent 326e0df commit 017d785

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

tests/biskotaki_ci/snapshot/test_matches_biskotaki_runtime_gen.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ def test_snapshot_matches_runtime(snapshot, biskotaki_ci_project, test_root):
9999
and 'settings.json' not in x.parts
100100
and '.tox' not in x.parts
101101
and '.mypy_cache' not in x.parts
102-
and x.parts not in {
102+
and x.parts
103+
not in {
103104
('reqs-prod+type.txt',),
104105
('gg-reqs.txt',),
105106
}

tests/test_snapshot_workflow_yaml.py

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
# def snapshot_project_data(request, test_root: Path) -> Path:
1010
# return test_root / 'data' / 'snapshots' / request.param, request.param
1111

12-
@pytest.mark.parametrize('snapshot', ["biskotaki-gold-standard", "biskotaki-no-input", "biskotaki-interactive"])
12+
13+
@pytest.mark.parametrize(
14+
'snapshot', ["biskotaki-gold-standard", "biskotaki-no-input", "biskotaki-interactive"]
15+
)
1316
def test_referenced_job_output_vars_correspond_to_existing_jobs(
1417
# GIVEN a Snapshot from calling the Generator
1518
# snapshot_project_data: t.Tuple[Path, str],
@@ -33,31 +36,41 @@ def test_referenced_job_output_vars_correspond_to_existing_jobs(
3336

3437
# GIVEN the EXPECTED paths to the generated Github Workflows per CICD Option
3538
from cookiecutter_python.hooks.post_gen_project import CICD_DELETE
39+
3640
d: t.Dict[str, t.List[t.Tuple[str, ...]]] = CICD_DELETE
3741

3842
all_rendered_yaml_workflows: t.Set[t.Tuple[str, ...]] = {
39-
tuple_of_strings for list_of_tuples in d.values() for tuple_of_strings in list_of_tuples
43+
tuple_of_strings
44+
for list_of_tuples in d.values()
45+
for tuple_of_strings in list_of_tuples
4046
}
41-
47+
4248
# Sanity check that the generated workflows are not empty, otherwise the test is pointless
4349
assert all_rendered_yaml_workflows, "No generated workflows found!"
44-
assert all([type(x) == tuple for x in all_rendered_yaml_workflows]), "All paths should be tuples of strings"
50+
assert all(
51+
[type(x) == tuple for x in all_rendered_yaml_workflows]
52+
), "All paths should be tuples of strings"
4553

4654
cicd_option_2_yaml_file_paths: t.Dict[CICDDesignOption, t.Iterable[Path]] = {
4755
# "stable": [test_root / '.github' / 'workflows' / 'test.yaml'],
4856
# "experimental": [test_root / '.github' / 'workflows' / 'cicd.yml'],
4957
cicd_option: [
5058
SNAPSHOT_PROJECT / Path(*workflow_path_tuple)
51-
for workflow_path_tuple in all_rendered_yaml_workflows if workflow_path_tuple not in set(CICD_DELETE[cicd_option])
59+
for workflow_path_tuple in all_rendered_yaml_workflows
60+
if workflow_path_tuple not in set(CICD_DELETE[cicd_option])
5261
]
5362
for cicd_option in CICD_OPTIONS
5463
}
5564
# assert cicd_option_2_yaml_file_paths == {}
56-
assert cicd_option_2_yaml_file_paths and all(cicd_option_2_yaml_file_paths.values()), "No workflows found!"
57-
assert all([type(x) == list for x in cicd_option_2_yaml_file_paths.values()]), "All values should be lists of paths"
65+
assert cicd_option_2_yaml_file_paths and all(
66+
cicd_option_2_yaml_file_paths.values()
67+
), "No workflows found!"
68+
assert all(
69+
[type(x) == list for x in cicd_option_2_yaml_file_paths.values()]
70+
), "All values should be lists of paths"
5871
assert type(cicd_option_2_yaml_file_paths['stable']) == list
5972
assert type(cicd_option_2_yaml_file_paths['experimental']) == list
60-
73+
6174
# GIVEN we maintain a registry of the cicd options used at generation time for every Snapshot
6275
snapshot_name_2_cicd_option_value: t.Dict[str, CICDDesignOption] = {
6376
'biskotaki-gold-standard': 'experimental',
@@ -68,7 +81,7 @@ def test_referenced_job_output_vars_correspond_to_existing_jobs(
6881
# GIVEN we identify the Snapshot's project cicd option used at generation time
6982
snapshot_cicd_value: CICDDesignOption = snapshot_name_2_cicd_option_value[SNAPSHOT_NAME]
7083

71-
# WHEN we iterate over the expected generated workflows for this Snapshot
84+
# WHEN we iterate over the expected generated workflows for this Snapshot
7285
import yaml
7386

7487
for yaml_workflow in cicd_option_2_yaml_file_paths[snapshot_cicd_value]:
@@ -82,20 +95,20 @@ def test_referenced_job_output_vars_correspond_to_existing_jobs(
8295
'Unable to parse YAML file {}. Error: {}' ''.format(yaml_workflow, error)
8396
) from error
8497
# THEN we check the yaml_dict that all jobs that reference variables from other jobs also depend on those jobs
85-
98+
8699
jobs: t.Dict[str, t.Dict[str, t.Any]] = yaml_dict["jobs"]
87-
100+
88101
for job_name, job_data in jobs.items():
89102
# we start small: only verify on jobs that call other reusable workflows
90103
if 'with' not in job_data:
91104
continue
92105
with_dict = job_data['with']
93-
106+
94107
# here every key maps to a reusable workflow input value
95-
108+
96109
# WHEN we scan all values passed to the reusable workflow
97110
# we try to find patterns such as '${{ needs.test_suite.outputs.PEP_VERSION }}'
98-
111+
99112
# AND verify that test_suite extracted is also in needs of job_data
100113
for key, value in with_dict.items():
101114
if not isinstance(value, str):
@@ -108,7 +121,9 @@ def test_referenced_job_output_vars_correspond_to_existing_jobs(
108121
job_name_referenced: str = parts[1].split('.')[0]
109122
# AND verify that job_name_referenced is in the jobs
110123
if job_name_referenced not in jobs:
111-
pytest.fail(f"Job {job_name} references variables from other jobs, but {job_name_referenced} is not a job.")
124+
pytest.fail(
125+
f"Job {job_name} references variables from other jobs, but {job_name_referenced} is not a job."
126+
)
112127

113128
# THEN we have successfully verified that all jobs that reference variables from other jobs also depend on those jobs
114129
# and the test passes

0 commit comments

Comments
 (0)