Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lldelisle committed Jul 1, 2024
1 parent 906c5ca commit 39480a8
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/data/wf_repos/basic_wf_iwc_invalid_version/.dockstore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 1.2
workflows:
- name: main
subclass: Galaxy
publish: true
primaryDescriptorPath: /Super-simple-workflow.ga
testParameterFiles:
- /Super-simple-workflow-tests.yml
authors:
- name: Lucille Delisle
orcid: 0000-0002-1964-4960
5 changes: 5 additions & 0 deletions tests/data/wf_repos/basic_wf_iwc_invalid_version/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## [0.1] 2024-06-17

First release.
3 changes: 3 additions & 0 deletions tests/data/wf_repos/basic_wf_iwc_invalid_version/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Super simple workflow

This is a super simple workflow which generates a file with x lines with 'hello'
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- doc: Test outline for Super-simple-workflow
job:
n_rows: 5
outputs:
outfile:
asserts:
has_n_lines:
n: 5
has_line:
line: "hello"
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"a_galaxy_workflow": "true",
"annotation": "This workflow generates a file with x lines with 'hello'",
"comments": [],
"creator": [
{
"class": "Person",
"identifier": "https://orcid.org/0000-0002-1964-4960",
"name": "Lucille Delisle"
}
],
"format-version": "0.1",
"license": "MIT",
"release": "0.2",
"name": "Super simple workflow",
"report": {
"markdown": "\n# Workflow Execution Report\n\n## Workflow Inputs\n```galaxy\ninvocation_inputs()\n```\n\n## Workflow Outputs\n```galaxy\ninvocation_outputs()\n```\n\n## Workflow\n```galaxy\nworkflow_display()\n```\n"
},
"steps": {
"0": {
"annotation": "Number of rows to generate",
"content_id": null,
"errors": null,
"id": 0,
"input_connections": {},
"inputs": [
{
"description": "Number of rows to generate",
"name": "n_rows"
}
],
"label": "n_rows",
"name": "Input parameter",
"outputs": [],
"position": {
"left": 0,
"top": 0
},
"tool_id": null,
"tool_state": "{\"parameter_type\": \"integer\", \"optional\": false}",
"tool_version": null,
"type": "parameter_input",
"uuid": "2ee42c13-83f5-4ac4-b35d-74294edf7dea",
"when": null
},
"1": {
"annotation": "this creates a file with a given number of lines",
"content_id": "toolshed.g2.bx.psu.edu/repos/bgruening/text_processing/tp_text_file_with_recurring_lines/9.3+galaxy1",
"errors": null,
"id": 1,
"input_connections": {
"token_set_0|repeat_select|times": {
"id": 0,
"output_name": "output"
}
},
"inputs": [],
"label": "create file",
"name": "Create text file",
"outputs": [
{
"name": "outfile",
"type": "txt"
}
],
"position": {
"left": 236,
"top": 11
},
"post_job_actions": {},
"tool_id": "toolshed.g2.bx.psu.edu/repos/bgruening/text_processing/tp_text_file_with_recurring_lines/9.3+galaxy1",
"tool_shed_repository": {
"changeset_revision": "fbf99087e067",
"name": "text_processing",
"owner": "bgruening",
"tool_shed": "toolshed.g2.bx.psu.edu"
},
"tool_state": "{\"token_set\": [{\"__index__\": 0, \"line\": \"hello\", \"repeat_select\": {\"repeat_select_opts\": \"user\", \"__current_case__\": 0, \"times\": {\"__class__\": \"ConnectedValue\"}}}], \"__page__\": null, \"__rerun_remap_job_id__\": null}",
"tool_version": "9.3+galaxy1",
"type": "tool",
"uuid": "a86ff433-8dce-417c-baf0-bc106a93ee48",
"when": null,
"workflow_outputs": [
{
"label": "outfile",
"output_name": "outfile",
"uuid": "34572088-8ad8-4661-81a2-6dfe2d83a0fe"
}
]
}
},
"tags": [],
"uuid": "72c87042-27a8-4bcc-92af-ca74704e6161",
"version": 3
}
38 changes: 38 additions & 0 deletions tests/test_cmd_workflow_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,44 @@ def test_workflow_linting_asserts(self):
result = self._runner.invoke(self._cli.planemo, lint_cmd)
assert "ERROR: Invalid assertion in tests: assert_has_line missing a required argument: 'line'" in result.output

def test_workflow_linting_iwc(self):
# Check the output of workflow_lint --iwc on a basic workflow with .dockstore
repo = _wf_repo("basic_format2_dockstore")
lint_cmd = ["workflow_lint", "--skip", "best_practices", "--iwc", repo]
result = self._runner.invoke(self._cli.planemo, lint_cmd)

errors = [
"The file README.md is missing but required.",
"The file CHANGELOG.md is missing but required.",
".dockstore.yml workflow entry missing recommended key name",
"Workflow have no 'authors' in the .dockstore.yml.",
"The workflow tests/data/wf_repos/basic_format2_dockstore/basic_format2.gxwf.yml has no release"
]

for error in errors:
assert error in result.output

# Check that skipping the good steps makes it work
lint_cmd = ["workflow_lint", "--iwc", "--skip", "best_practices,required_files,dockstore_best_practices,release", repo]
self._check_exit_code(lint_cmd, exit_code=0)

# Check the output of workflow_lint --iwc on a good workflow but with an issue with the release
repo = _wf_repo("basic_wf_iwc_invalid_version")
lint_cmd = ["workflow_lint", "--iwc", repo]
result = self._runner.invoke(self._cli.planemo, lint_cmd)

errors = [
"The release of workflow",
" does not match the version in the CHANGELOG."
]

for error in errors:
assert error in result.output

# Check that skipping the good steps makes it work
lint_cmd = ["workflow_lint", "--iwc", "--skip", "release", repo]
self._check_exit_code(lint_cmd, exit_code=0)


def _wf_repo(rel_path):
return os.path.join(TEST_DATA_DIR, "wf_repos", rel_path)

0 comments on commit 39480a8

Please sign in to comment.