2018-07-11 08:50:42 -04:00
|
|
|
"""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):
|
2018-07-11 08:50:42 -04:00
|
|
|
"""Validate introspection category"""
|
|
|
|
if name:
|
2023-07-10 15:43:17 -04:00
|
|
|
run = runner(command=yadm_cmd("introspect", name))
|
2018-07-11 08:50:42 -04:00
|
|
|
else:
|
2023-07-10 15:43:17 -04:00
|
|
|
run = runner(command=yadm_cmd("introspect"))
|
2018-07-11 08:50:42 -04:00
|
|
|
|
|
|
|
assert run.success
|
2023-07-10 15:43:17 -04:00
|
|
|
assert run.err == ""
|
2018-07-11 08:50:42 -04:00
|
|
|
|
|
|
|
expected = []
|
2023-07-10 15:43:17 -04:00
|
|
|
if name == "commands":
|
2018-07-11 08:50:42 -04:00
|
|
|
expected = supported_commands
|
2023-07-10 15:43:17 -04:00
|
|
|
elif name == "configs":
|
2018-07-11 08:50:42 -04:00
|
|
|
expected = supported_configs
|
2023-07-10 15:43:17 -04:00
|
|
|
elif name == "switches":
|
2018-07-11 08:50:42 -04:00
|
|
|
expected = supported_switches
|
|
|
|
|
|
|
|
# assert values
|
2023-07-10 15:43:17 -04:00
|
|
|
if name in ("", "invalid"):
|
|
|
|
assert run.out == ""
|
|
|
|
if name == "repo":
|
2018-07-11 08:50:42 -04:00
|
|
|
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)
|