1
0
Fork 0
mirror of synced 2024-11-18 23:25:35 -05:00
yadm/test/test_introspect.py

47 lines
1.1 KiB
Python
Raw Permalink Normal View History

"""Test introspect"""
import pytest
@pytest.mark.parametrize(
2023-07-10 15:43:17 -04:00
"name",
[
"",
"invalid",
"commands",
"configs",
"repo",
"switches",
],
)
def test_introspect_category(runner, yadm_cmd, paths, name, supported_commands, supported_configs, supported_switches):
"""Validate introspection category"""
if name:
2023-07-10 15:43:17 -04:00
run = runner(command=yadm_cmd("introspect", name))
else:
2023-07-10 15:43:17 -04:00
run = runner(command=yadm_cmd("introspect"))
assert run.success
2023-07-10 15:43:17 -04:00
assert run.err == ""
expected = []
2023-07-10 15:43:17 -04:00
if name == "commands":
expected = supported_commands
2023-07-10 15:43:17 -04:00
elif name == "configs":
expected = supported_configs
2023-07-10 15:43:17 -04:00
elif name == "switches":
expected = supported_switches
# assert values
2023-07-10 15:43:17 -04:00
if name in ("", "invalid"):
assert run.out == ""
if name == "repo":
assert run.out.rstrip() == paths.repo
# make sure every expected value is present
for value in expected:
assert value in run.out
# make sure nothing extra is present
if expected:
assert len(run.out.split()) == len(expected)