summaryrefslogtreecommitdiff
path: root/test/test_introspect.py
blob: b292bd489f1a3af1ea4a16bfe906e1209fd1bfea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Test introspect"""

import pytest


@pytest.mark.parametrize(
    '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:
        run = runner(command=yadm_cmd('introspect', name))
    else:
        run = runner(command=yadm_cmd('introspect'))

    assert run.success
    assert run.err == ''

    expected = []
    if name == 'commands':
        expected = supported_commands
    elif name == 'configs':
        expected = supported_configs
    elif name == 'switches':
        expected = supported_switches

    # assert values
    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)