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

TestUtils.test_int_dpid()   A

Complexity

Conditions 3

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
nop 1
dl 0
loc 15
rs 9.85
c 0
b 0
f 0
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