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
|
|
|
|