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
2 changes: 1 addition & 1 deletion rocrate_validator/cli/commands/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def validate_uri(ctx, param, value):
@click.option(
"-o",
"--output-file",
type=click.Path(),
type=click.Path(path_type=Path),
default=None,
show_default=True,
help="Path to the output file for the validation report",
Expand Down
42 changes: 42 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import re
from pathlib import Path
from unittest.mock import patch
Expand Down Expand Up @@ -146,6 +147,47 @@ def mock_validate(*args, **kwargs):
)


def test_validate_output_file_text_report(cli_runner: CliRunner, tmp_path: Path):
output_file = tmp_path / "report.txt"
result = cli_runner.invoke(
cli,
[
"validate",
str(ValidROC().wrroc_paper_long_date),
"--verbose",
"--no-paging",
"-o",
str(output_file),
],
)
assert result.exit_code == 0, result.output
assert "AttributeError" not in result.output
assert output_file.exists(), "The text report file was not created"
assert output_file.read_text(encoding="utf-8").strip(), "The text report file is empty"


def test_validate_output_file_json_report(cli_runner: CliRunner, tmp_path: Path):
output_file = tmp_path / "report.json"
result = cli_runner.invoke(
cli,
[
"validate",
str(ValidROC().wrroc_paper_long_date),
"--no-paging",
"--output-format",
"json",
"-w",
"10000",
"-o",
str(output_file),
],
)
assert result.exit_code == 0, result.output
assert "AttributeError" not in result.output
assert output_file.exists(), "The JSON report file was not created"
json.loads(output_file.read_text(encoding="utf-8")) # must be valid JSON


def test_validate_with_invalid_profiles_path_dir(cli_runner: CliRunner):
dummy_profiles_path = "/tmp/dummy_profiles"
result = cli_runner.invoke(
Expand Down