|
1
|
|
|
"""Conftest.""" |
|
2
|
|
|
from unittest.mock import MagicMock |
|
3
|
|
|
|
|
4
|
|
|
import pytest |
|
5
|
|
|
from kytos.lib.helpers import get_interface_mock, get_switch_mock |
|
6
|
|
|
|
|
7
|
|
|
from napps.kytos.of_lldp.controllers import LivenessController |
|
8
|
|
|
from napps.kytos.of_lldp.managers.liveness import ILSM, LSM, LivenessManager |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
@pytest.fixture(autouse=True) |
|
12
|
|
|
def ev_loop(monkeypatch, event_loop) -> None: |
|
13
|
|
|
"""asyncio event loop autouse fixture.""" |
|
14
|
|
|
monkeypatch.setattr("asyncio.get_running_loop", lambda: event_loop) |
|
15
|
|
|
yield event_loop |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
@pytest.fixture |
|
19
|
|
|
def ilsm() -> None: |
|
20
|
|
|
"""ISLM fixture.""" |
|
21
|
|
|
return ILSM() |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
@pytest.fixture |
|
25
|
|
|
def lsm() -> None: |
|
26
|
|
|
"""LSM fixture.""" |
|
27
|
|
|
return LSM(ILSM(), ILSM()) |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
@pytest.fixture |
|
31
|
|
|
def switch_one(): |
|
32
|
|
|
"""Switch one fixture.""" |
|
33
|
|
|
return get_switch_mock("00:00:00:00:00:00:00:01", 0x04) |
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
@pytest.fixture |
|
37
|
|
|
def switch_two(): |
|
38
|
|
|
"""Switch one fixture.""" |
|
39
|
|
|
return get_switch_mock("00:00:00:00:00:00:00:02", 0x04) |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
@pytest.fixture |
|
43
|
|
|
def intf_one(switch_one): |
|
44
|
|
|
"""Interface one fixture.""" |
|
45
|
|
|
return get_interface_mock("s1-eth1", 1, switch_one) |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
@pytest.fixture |
|
49
|
|
|
def intf_two(switch_two): |
|
50
|
|
|
"""Interface two fixture.""" |
|
51
|
|
|
return get_interface_mock("s2-eth1", 1, switch_two) |
|
52
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
@pytest.fixture |
|
55
|
|
|
def intf_three(switch_two): |
|
56
|
|
|
"""Interface three fixture.""" |
|
57
|
|
|
return get_interface_mock("s2-eth2", 2, switch_two) |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
@pytest.fixture |
|
61
|
|
|
def liveness_manager(): |
|
62
|
|
|
"""LivenessManager fixture.""" |
|
63
|
|
|
return LivenessManager(MagicMock()) |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
@pytest.fixture |
|
67
|
|
|
def liveness_controller() -> None: |
|
68
|
|
|
"""LivenessController.""" |
|
69
|
|
|
return LivenessController(MagicMock()) |
|
70
|
|
|
|