Passed
Pull Request — master (#435)
by Carlos Eduardo
02:34
created

TestPortStatus.test_unpack()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
1
"""Port Status message tests."""
2
from pyof.foundation.basic_types import HWAddress
3
from pyof.foundation.constants import OFP_MAX_PORT_NAME_LEN
4
from pyof.v0x01.asynchronous.port_status import PortReason, PortStatus
5
from pyof.v0x01.common.phy_port import (
6
    PhyPort, PortConfig, PortFeatures, PortState)
7
from tests.test_struct import TestStruct
8
9
10
class TestPortStatus(TestStruct):
11
    """Test the Port Status message."""
12
13
    @classmethod
14
    def setUpClass(cls):
15
        """Configure raw file and its object in parent class (TestDump)."""
16
        super().setUpClass()
17
        super().set_raw_dump_object(_new_portstatus)
18
        super().set_minimum_size(64)
19
20
21
def _new_portstatus():
22
    """Crate new PortStatus and PhyPort instances."""
23
    desc_name = 'X' * OFP_MAX_PORT_NAME_LEN
24
    desc = PhyPort(port_no=2,
25
                   hw_addr=HWAddress('0a:0a:12:12:10:10'),
26
                   name=desc_name,
27
                   config=PortConfig.OFPPC_NO_STP,
28
                   state=PortState.OFPPS_STP_FORWARD,
29
                   curr=PortFeatures.OFPPF_10GB_FD,
30
                   advertised=PortFeatures.OFPPF_PAUSE,
31
                   supported=PortFeatures.OFPPF_AUTONEG,
32
                   peer=PortFeatures.OFPPF_AUTONEG)
33
    return PortStatus(xid=1,
34
                      reason=PortReason.OFPPR_ADD,
35
                      desc=desc)
36