Total Complexity | 3 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """Module to test the utls.py file.""" |
||
2 | from unittest import TestCase |
||
3 | from unittest.mock import MagicMock |
||
4 | |||
5 | from napps.kytos.mef_eline.utils import compare_endpoint_trace |
||
6 | |||
7 | |||
8 | # pylint: disable=too-many-public-methods, too-many-lines |
||
9 | class TestUtils(TestCase): |
||
10 | """Test utility functions.""" |
||
11 | |||
12 | def test_compare_endpoint_trace(self): |
||
13 | """Test method compare_endpoint_trace""" |
||
14 | |||
15 | trace = {"dpid": "1234", "port": 2, "vlan": 123} |
||
16 | |||
17 | switch1 = MagicMock() |
||
18 | switch1.dpid = "1234" |
||
19 | switch2 = MagicMock() |
||
20 | switch2.dpid = "2345" |
||
21 | |||
22 | endpoint = MagicMock() |
||
23 | endpoint.port_number = 2 |
||
24 | vlan = 123 |
||
25 | |||
26 | for switch, expected in ((switch1, True), (switch2, False)): |
||
27 | with self.subTest(switch=switch, expected=expected): |
||
28 | endpoint.switch = switch |
||
29 | self.assertEqual( |
||
30 | compare_endpoint_trace(endpoint, vlan, trace), expected |
||
31 | ) |
||
32 |