Passed
Push — master ( 75d007...4d9626 )
by Humberto
01:10 queued 12s
created

TestMatch.test_dl_vlan_dict()   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
"""Test Match abstraction for v0x04."""
2
import unittest
3
4
from napps.kytos.of_core.v0x04.flow import Match
5
from napps.kytos.of_core.v0x04.match_fields import MatchDLVLAN
6
7
8
class TestMatch(unittest.TestCase):
9
    """Tests for the Match class."""
10
11
    def test_dl_vlan_dict(self):
12
        """Convert from JSON dict to OF Match."""
13
        match_dict = {'dl_vlan': 42}
14
        match = Match.from_dict(match_dict)
15
        self.assertEqual(42, match.dl_vlan)
16
17
    def test_dl_vlan_pyof(self):
18
        """Convert to and from pyof OxmTLV."""
19
        expected = MatchDLVLAN(42)
20
        of_tlv = expected.as_of_tlv()
21
        actual = MatchDLVLAN.from_of_tlv(of_tlv)
22
        self.assertEqual(expected, actual)
23