Skip to content

Commit

Permalink
feat(cli): upload test files from spec automatically (reanahub#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajclyall committed Aug 6, 2024
1 parent 5d7224d commit 1c92a87
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions reana_client/cli/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ def upload_files( # noqa: C901
)
sys.exit(1)
filenames.append(os.path.join(os.getcwd(), f))
if reana_spec.get("tests"):
for f in reana_spec["tests"].get("files") or []:
filenames.append(os.path.join(os.getcwd(), f))

# collect all files in input.directories
files_from_directories = []
Expand Down
29 changes: 29 additions & 0 deletions tests/test_cli_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,35 @@ def test_upload_file(create_yaml_workflow_schema):
assert message in result.output


def test_upload_file_with_test_files_from_spec(
get_workflow_specification_with_directory,
):
"""Test upload file with test files from the specification, not from the command line."""
reana_token = "000000"
file = "upload-this-test.feature"
env = {"REANA_SERVER_URL": "http://localhost"}
runner = CliRunner(env=env)

with patch(
"reana_client.api.client.get_workflow_specification"
) as mock_specification, patch("reana_client.api.client.requests.post"):
with runner.isolated_filesystem():
with open(file, "w") as f:
f.write("Scenario: Test scenario")

get_workflow_specification_with_directory["specification"]["tests"] = {
"files": [file]
}
mock_specification.return_value = get_workflow_specification_with_directory
result = runner.invoke(
cli, ["upload", "-t", reana_token, "--workflow", "test-workflow.1"]
)
assert result.exit_code == 0
assert (
"upload-this-test.feature was successfully uploaded." in result.output
)


def test_upload_file_respect_gitignore(
get_workflow_specification_with_directory,
):
Expand Down

0 comments on commit 1c92a87

Please sign in to comment.