Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/ocrd_network/cli/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ def send_workflow_job_request(
as in ``ocrd process`` tasks arguments), or via `-w` file path
(same syntax, but newline separated).
"""
if (path_to_workflow) != bool(len(tasks)):
raise ValueError("either -w/path-to-workflow or task argument(s) is required")
if bool(path_to_workflow) == bool(len(tasks)):
diag = 'not both' if bool(path_to_workflow) else 'but neither was provided'
raise ValueError(f"Either -w/--path-to-workflow option or task argument(s) is required, {diag}.")

client = Client(server_addr_processing=address)
with NamedTemporaryFile() as workflow_file:
Expand Down
26 changes: 26 additions & 0 deletions tests/cli/test_network.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import re
from click.testing import CliRunner
import pytest
from ocrd_network.cli.client import workflow_cli


runner = CliRunner()

def test_check_workflow_tasks_argument():
"""
https://github.com/OCR-D/core/pull/1358
"""
with pytest.raises(ValueError, match=re.escape("Either -w/--path-to-workflow option or task argument(s) is required, but neither was provided.")):
runner.invoke(workflow_cli, [
'run',
'--address', 'https://irrelevant',
'--path-to-mets', 'irrelevant',
], catch_exceptions=False)
with pytest.raises(ValueError, match=re.escape("Either -w/--path-to-workflow option or task argument(s) is required, not both.")):
runner.invoke(workflow_cli, [
'run',
'--address', 'https://irrelevant',
'--path-to-mets', 'irrelevant',
'--path-to-workflow', 'irrelevant',
'task1', 'task2'
], catch_exceptions=False)
Loading