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