Test Failed
Push — master ( dba1ae...723a1d )
by Antonio
04:50 queued 13s
created

build.tests.unit.test_utils   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A TestUtils.test_compare_endpoint_trace() 0 24 3
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