Skip to content

Commit

Permalink
fix linting test
Browse files Browse the repository at this point in the history
  • Loading branch information
mashehu committed May 8, 2024
1 parent bd8e46e commit bda8d42
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/lint/actions_schema_validation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
from pathlib import Path

import yaml

Expand All @@ -9,10 +9,11 @@ def test_actions_schema_validation_missing_jobs(self):
"""Missing 'jobs' field should result in failure"""
new_pipeline = self._make_pipeline_copy()

with open(os.path.join(new_pipeline, ".github", "workflows", "awstest.yml")) as fh:
awstest_yml_path = Path(new_pipeline) / ".github" / "workflows" / "awstest.yml"
with open(awstest_yml_path) as fh:
awstest_yml = yaml.safe_load(fh)
awstest_yml.pop("jobs")
with open(os.path.join(new_pipeline, ".github", "workflows", "awstest.yml"), "w") as fh:
with open(awstest_yml_path, "w") as fh:
yaml.dump(awstest_yml, fh)

lint_obj = nf_core.lint.PipelineLint(new_pipeline)
Expand All @@ -27,29 +28,31 @@ def test_actions_schema_validation_missing_on(self):
"""Missing 'on' field should result in failure"""
new_pipeline = self._make_pipeline_copy()

with open(os.path.join(new_pipeline, ".github", "workflows", "awstest.yml")) as fh:
awstest_yml_path = Path(new_pipeline) / ".github" / "workflows" / "awstest.yml"
with open(awstest_yml_path) as fh:
awstest_yml = yaml.safe_load(fh)
awstest_yml.pop(True)
with open(os.path.join(new_pipeline, ".github", "workflows", "awstest.yml"), "w") as fh:
with open(awstest_yml_path, "w") as fh:
yaml.dump(awstest_yml, fh)

lint_obj = nf_core.lint.PipelineLint(new_pipeline)
lint_obj._load()

results = lint_obj.actions_schema_validation()

assert results["failed"][0] == "Missing 'on' keyword in {}.format(wf)"
assert results["failed"][0] == "Missing 'on' keyword in awstest.yml"
assert "Workflow validation failed for awstest.yml: 'on' is a required property" in results["failed"][1]


def test_actions_schema_validation_fails_for_additional_property(self):
"""Missing 'jobs' field should result in failure"""
new_pipeline = self._make_pipeline_copy()

with open(os.path.join(new_pipeline, ".github", "workflows", "awstest.yml")) as fh:
awstest_yml_path = Path(new_pipeline) / ".github" / "workflows" / "awstest.yml"
with open(awstest_yml_path) as fh:
awstest_yml = yaml.safe_load(fh)
awstest_yml["not_jobs"] = awstest_yml["jobs"]
with open(os.path.join(new_pipeline, ".github", "workflows", "awstest.yml"), "w") as fh:
with open(awstest_yml_path, "w") as fh:
yaml.dump(awstest_yml, fh)

lint_obj = nf_core.lint.PipelineLint(new_pipeline)
Expand Down

0 comments on commit bda8d42

Please sign in to comment.