Passed
Push — master ( 25a700...042c2b )
by Vinicius
01:48 queued 17s
created

build.tests.unit.test_utils   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A TestUtils.test_get_cookie() 0 5 1
A TestUtils.test_int_dpid() 0 15 3
1
"""Test utils module."""
2
from unittest import TestCase
3
4
from napps.kytos.of_lldp.utils import get_cookie, int_dpid
5
6
7
class TestUtils(TestCase):
8
    """Tests for the utils module."""
9
10
    def test_int_dpid(self):
11
        """Test int dpid."""
12
        test_data = [
13
            (
14
                "21:00:10:00:00:00:00:02",
15
                0x2100100000000002,
16
            ),
17
            (
18
                "00:00:00:00:00:00:00:07",
19
                0x0000000000000007,
20
            ),
21
        ]
22
        for dpid, expected_dpid in test_data:
23
            with self.subTest(dpid=dpid, expected_dpid=expected_dpid):
24
                assert int_dpid(dpid) == expected_dpid
25
26
    @staticmethod
27
    def test_get_cookie():
28
        """Test get_cookie."""
29
        dpid = "00:00:00:00:00:00:00:01"
30
        assert hex(get_cookie(dpid)) == hex(0xab00000000000001)
31