compose-viz/tests/test_cli.py

42 lines
1.3 KiB
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",
2022-06-08 18:21:54 +02:00
"tests/ymls/cgroup_parent/docker-compose.yml",
"tests/ymls/container_name/docker-compose.yml",
2022-05-25 11:16:38 +02:00
"tests/ymls/depends_on/docker-compose.yml",
2022-06-08 18:21:54 +02:00
"tests/ymls/devices/docker-compose.yml",
"tests/ymls/env_file/docker-compose.yml",
"tests/ymls/expose/docker-compose.yml",
2022-05-25 11:16:38 +02:00
"tests/ymls/extends/docker-compose.yml",
"tests/ymls/links/docker-compose.yml",
"tests/ymls/networks/docker-compose.yml",
"tests/ymls/ports/docker-compose.yml",
2022-06-08 18:21:54 +02:00
"tests/ymls/profiles/docker-compose.yml",
2022-05-25 11:16:38 +02:00
"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-26 05:10:19 +02:00
output_filename = "compose-viz-test"
default_format = "png"
result = runner.invoke(cli.app, ["-o", output_filename, 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-26 05:10:19 +02:00
assert os.path.exists(f"{output_filename}.{default_format}")
2022-05-18 16:47:54 +02:00
2022-05-26 05:10:19 +02:00
os.remove(f"{output_filename}.{default_format}")