summaryrefslogtreecommitdiffstats
path: root/test/t/test_ip.py
blob: 552015de81f6acefca433621b78b26572b835a99 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pytest


class TestIp:
    @pytest.mark.complete("ip ")
    def test_1(self, completion):
        assert completion

    @pytest.mark.complete("ip a ")
    def test_2(self, completion):
        assert completion

    @pytest.mark.complete("ip route replace ", require_cmd=True)
    def test_r_r(self, completion):
        assert completion

    @pytest.mark.complete(
        "ip stats show group ",
        require_cmd=True,
        skipif="ip stats help 2>/dev/null; (( $? != 255 ))",
    )
    def test_stats(self, completion):
        # "link" was one of the first groups added, should always be there
        assert "link" in completion

    @pytest.mark.complete(
        "ip neigh show nud ",
        require_cmd=True,
        skipif="ip neigh help 2>&1 | grep 'STATE :=' > /dev/null; (( $? != 0 ))",
    )
    def test_neigh_state(self, completion):
        assert "stale" in completion

    @pytest.mark.complete(
        "ip monitor ",
        require_cmd=True,
        skipif="ip monitor help 2>/dev/null; (( $? != 255 ))",
    )
    def test_monitor(self, completion):
        assert "neigh" in completion
        assert "all" in completion

    @pytest.mark.complete("ip netconf ")
    def test_netconf(self, completion):
        assert "show" in completion

    @pytest.mark.complete("ip link property add ")
    def test_link_property(self, completion):
        assert "altname" in completion
        assert "dev" in completion

    @pytest.mark.complete(
        "ip addr show type ",
        require_cmd=True,
        skipif="ip link help 2>/dev/null; (( $? != 255 ))",
    )
    def test_addr_type(self, completion):
        assert "bridge" in completion

    @pytest.mark.complete("ip -", require_cmd=True)
    def test_options(self, completion):
        assert "-family" in completion