build.tests.integration.v0x04.test_match   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 14
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A TestMatch.test_dl_vlan_dict() 0 5 1
A TestMatch.test_dl_vlan_pyof() 0 6 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