Test Failed
Pull Request — master (#404)
by
unknown
01:46
created

TestMatch.test_pack_unpack()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
1
"""Testing FlowMatch structure."""
2
from pyof.foundation.basic_types import HWAddress, IPAddress
3
from pyof.v0x01.common.flow_match import Match
4
from tests.test_struct import TestStructDump
5
6
7
class TestMatch(TestStructDump):
8
    """Test Match structure."""
9
10
    dump = b'\x00\x0f\xff\x00\x00\x16\x01\x02\x03\x04\x05\x06\x01\x02\x03\x04'
11
    dump += b'\x05\x06\x00\x01\x01\x00\x00\x01\x01\x01\x00\x00\xc0\xa8\x00\x01'
12
    dump += b'\xc0\xa8\x00\x02\x00\x16\x00\x16'  # needs to be checked
13
    obj = Match(in_port=22,
14
                dl_src=[1, 2, 3, 4, 5, 6],
15
                dl_dst=[1, 2, 3, 4, 5, 6],
16
                dl_vlan=1,
17
                dl_vlan_pcp=1,
18
                dl_type=1,
19
                nw_tos=1,
20
                nw_proto=1,
21
                nw_src=[192, 168, 0, 1],
22
                nw_dst=[192, 168, 0, 2],
23
                tp_src=22,
24
                tp_dst=22)
25
26
27
class TestMatch2(TestStructDump):
28
    """Test Match structure."""
29
30
    dump = b'\x00\x0f\xff\x0c\x00P\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
31
    dump += b'\x00\x00\x00\x01\x01\x00\x00\x01\x01\x01\x00\x00\xc0\xa8\x00'
32
    dump += b'\x01\xc0\xa8\x00\x02\x00P\x00P'
33
    obj = Match(in_port=80, dl_vlan=1, dl_vlan_pcp=1, dl_type=1,
34
                nw_tos=1, nw_proto=1, tp_src=80, tp_dst=80,
35
                dl_src=HWAddress('00:00:00:00:00:00'),
36
                dl_dst=HWAddress('00:00:00:00:00:00'),
37
                nw_src=IPAddress('192.168.0.1'),
38
                nw_dst=IPAddress('192.168.0.2'))
39