Passed
Push — master ( b50e97...feedcb )
by Humberto
01:28 queued 14s
created

tests.unit.v0x01.test_controller2switch.test_features_reply   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 46
dl 0
loc 56
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A TestFeaturesReply.setUpClass() 0 8 1

2 Functions

Rating   Name   Duplication   Size   Complexity  
A _get_kwargs() 0 4 1
A _get_ports() 0 29 1
1
"""Echo request message tests."""
2
from pyof.foundation.basic_types import DPID, HWAddress
3
from pyof.v0x01.common.phy_port import PhyPort, PortConfig, PortState
4
from pyof.v0x01.controller2switch.features_reply import FeaturesReply
5
from tests.unit.test_struct import TestStruct
6
7
8
class TestFeaturesReply(TestStruct):
9
    """Feature reply message tests (also those in :class:`.TestDump`)."""
10
11
    @classmethod
12
    def setUpClass(cls):
13
        """Configure raw file and its object in parent class (TestDump)."""
14
        super().setUpClass()
15
        super().set_raw_dump_file('v0x01', 'ofpt_features_reply')
16
        kwargs = _get_kwargs()
17
        super().set_raw_dump_object(FeaturesReply, **kwargs)
18
        super().set_minimum_size(32)
19
20
21
def _get_kwargs():
22
    return {'xid': 2, 'datapath_id': DPID('00:00:00:00:00:00:00:01'),
23
            'n_buffers': 256, 'n_tables': 254, 'capabilities': 0x000000c7,
24
            'actions': 4095, 'ports': _get_ports()}
25
26
27
def _get_ports():
28
    return [
29
        PhyPort(port_no=65534,
30
                hw_addr=HWAddress('0e:d3:98:a5:30:47'),
31
                name='s1',
32
                config=PortConfig.OFPPC_PORT_DOWN,
33
                state=PortState.OFPPS_LINK_DOWN,
34
                curr=0,
35
                advertised=0,
36
                supported=0,
37
                peer=0),
38
        PhyPort(port_no=1,
39
                hw_addr=HWAddress('0a:54:cf:fc:4e:6d'),
40
                name='s1-eth1',
41
                config=0,
42
                state=PortState.OFPPS_STP_LISTEN,
43
                curr=0x000000c0,
44
                advertised=0,
45
                supported=0,
46
                peer=0),
47
        PhyPort(port_no=2,
48
                hw_addr=HWAddress('f6:b6:ab:cc:f8:4f'),
49
                name='s1-eth2',
50
                config=0,
51
                state=PortState.OFPPS_STP_LISTEN,
52
                curr=0x000000c0,
53
                advertised=0,
54
                supported=0,
55
                peer=0)
56
    ]
57