| Total Complexity | 3 |
| Total Lines | 36 |
| 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 = { |
||
| 16 | "dpid": "1234", |
||
| 17 | "port": 2, |
||
| 18 | "vlan": 123 |
||
| 19 | } |
||
| 20 | |||
| 21 | switch1 = MagicMock() |
||
| 22 | switch1.dpid = "1234" |
||
| 23 | switch2 = MagicMock() |
||
| 24 | switch2.dpid = "2345" |
||
| 25 | |||
| 26 | endpoint = MagicMock() |
||
| 27 | endpoint.port_number = 2 |
||
| 28 | vlan = 123 |
||
| 29 | |||
| 30 | for switch, expected in ((switch1, True), (switch2, False)): |
||
| 31 | with self.subTest(switch=switch, expected=expected): |
||
| 32 | endpoint.switch = switch |
||
| 33 | self.assertEqual( |
||
| 34 | compare_endpoint_trace(endpoint, vlan, trace), |
||
| 35 | expected |
||
| 36 | ) |
||
| 37 |