TestUtils.test_compare_endpoint_trace()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 14
nop 1
dl 0
loc 19
rs 9.7
c 0
b 0
f 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