compose-viz/tests/test_cli.py

35 lines
988 B
Python
Raw Normal View History

2022-05-16 18:57:14 +02:00
import os
2022-05-18 17:28:18 +02:00
import pytest
2022-05-07 18:42:14 +02:00
from typer.testing import CliRunner
2022-05-18 17:28:18 +02:00
from compose_viz import cli
2022-05-07 18:42:14 +02:00
runner = CliRunner()
2022-05-18 17:28:18 +02:00
@pytest.mark.parametrize(
2022-05-24 10:02:47 +02:00
"test_file_path",
2022-05-18 17:28:18 +02:00
[
2022-05-25 11:16:38 +02:00
"tests/ymls/builds/docker-compose.yml",
"tests/ymls/depends_on/docker-compose.yml",
"tests/ymls/extends/docker-compose.yml",
"tests/ymls/links/docker-compose.yml",
"tests/ymls/networks/docker-compose.yml",
"tests/ymls/ports/docker-compose.yml",
"tests/ymls/volumes/docker-compose.yml",
"examples/full-stack-node-app/docker-compose.yml",
2022-05-25 11:46:53 +02:00
"examples/non-normative/docker-compose.yml",
2022-05-18 17:28:18 +02:00
],
)
2022-05-24 10:02:47 +02:00
def test_cli(test_file_path: str) -> None:
2022-05-25 11:16:38 +02:00
input_path = f"{test_file_path}"
2022-05-24 10:02:47 +02:00
output_path = "compose-viz-test.png"
2022-05-18 16:47:54 +02:00
result = runner.invoke(cli.app, ["-o", output_path, input_path])
2022-05-07 18:42:14 +02:00
assert result.exit_code == 0
assert f"Successfully parsed {input_path}\n" in result.stdout
2022-05-18 16:47:54 +02:00
assert os.path.exists(output_path)
os.remove(output_path)