]> git.ipfire.org Git - thirdparty/lldpd.git/blob - tests/integration/test_dot3.py
tests: replace integration test by py.test+namespace tests
[thirdparty/lldpd.git] / tests / integration / test_dot3.py
1 import pytest
2 import pyroute2
3 import shlex
4 import time
5
6
7 @pytest.mark.skipif('Dot3' not in pytest.config.lldpd.features,
8 reason="Dot3 not supported")
9 class TestLldpDot3(object):
10
11 def test_aggregate(self, lldpd1, lldpd, lldpcli, namespaces, links):
12 links(namespaces(3), namespaces(2)) # Another link to setup a bond
13 with namespaces(2):
14 idx = links.bond('bond42', 'eth1', 'eth3')
15 lldpd()
16 with namespaces(1):
17 out = lldpcli("-f", "keyvalue", "show", "neighbors", "details")
18 assert out['lldp.eth0.port.descr'] == 'eth1'
19 assert out['lldp.eth0.port.aggregation'] == str(idx)
20
21 # TODO: unfortunately, with veth, it's not possible to get an
22 # interface with autoneg.
23
24 @pytest.mark.parametrize("command, expected", [
25 ("pse supported enabled paircontrol powerpairs spare class class-3",
26 {'supported': 'yes',
27 'enabled': 'yes',
28 'paircontrol': 'yes',
29 'device-type': 'PSE',
30 'pairs': 'spare',
31 'class': 'class 3'}),
32 ("pd supported enabled powerpairs spare class class-3 type 1 source "
33 "pse priority low requested 10000 allocated 15000",
34 {'supported': 'yes',
35 'enabled': 'yes',
36 'paircontrol': 'no',
37 'device-type': 'PD',
38 'pairs': 'spare',
39 'class': 'class 3',
40 'power-type': '1',
41 'source': 'Primary power source',
42 'priority': 'low',
43 'requested': '10000',
44 'allocated': '15000'})])
45 def test_power(self, lldpd1, lldpd, lldpcli, namespaces,
46 command, expected):
47 with namespaces(2):
48 lldpd()
49 result = lldpcli(
50 *shlex.split("configure dot3 power {}".format(command)))
51 assert result.returncode == 0
52 time.sleep(2)
53 with namespaces(1):
54 pfx = "lldp.eth0.port.power."
55 out = lldpcli("-f", "keyvalue", "show", "neighbors", "details")
56 out = {k[len(pfx):]: v
57 for k, v in out.items()
58 if k.startswith(pfx)}
59 assert out == expected