File: test_port_desc.py

package info (click to toggle)
python-openflow 2021.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,224 kB
  • sloc: python: 6,906; sh: 4; makefile: 4
file content (63 lines) | stat: -rw-r--r-- 2,335 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""MultipartReply message test."""

from pyof.foundation.basic_types import HWAddress
from pyof.v0x04.common.port import (
    ListOfPorts, Port, PortConfig, PortFeatures, PortNo, PortState)
from pyof.v0x04.controller2switch.common import MultipartType
from pyof.v0x04.controller2switch.multipart_reply import MultipartReply
from tests.unit.test_struct import TestStruct


class TestPortDesc(TestStruct):
    """Test PortDesc."""

    @classmethod
    def setUpClass(cls):
        """Configure raw file and its object in parent class (TestDump)."""
        mp_type = MultipartType.OFPMP_PORT_DESC
        super().setUpClass()
        super().set_raw_dump_file('v0x04', 'ofpt_port_desc')
        super().set_raw_dump_object(MultipartReply, xid=1917225664,
                                    multipart_type=mp_type,
                                    flags=0,
                                    body=_get_body())
        super().set_minimum_size(16)


def _get_body():
    """Return the body used by MultipartReply message."""
    port1 = Port(port_no=PortNo.OFPP_LOCAL,
                 hw_addr=HWAddress('5a:ee:a5:a0:62:4f'),
                 name='s1',
                 config=PortConfig.OFPPC_PORT_DOWN,
                 state=PortState.OFPPS_LINK_DOWN,
                 curr=0,
                 advertised=0,
                 supported=0,
                 peer=0,
                 curr_speed=0,
                 max_speed=0)
    port2 = Port(port_no=1,
                 hw_addr=HWAddress('4e:bf:ca:27:8e:ca'),
                 name='s1-eth1',
                 config=0,
                 state=PortState.OFPPS_LIVE,
                 curr=PortFeatures.OFPPF_10GB_FD | PortFeatures.OFPPF_COPPER,
                 advertised=0,
                 supported=0,
                 peer=0,
                 curr_speed=10000000,
                 max_speed=0)
    port3 = Port(port_no=2,
                 hw_addr=HWAddress('26:1f:b9:5e:3c:c7'),
                 name='s1-eth2',
                 config=0,
                 state=PortState.OFPPS_LIVE,
                 curr=PortFeatures.OFPPF_10GB_FD | PortFeatures.OFPPF_COPPER,
                 advertised=0,
                 supported=0,
                 peer=0,
                 curr_speed=10000000,
                 max_speed=0)
    lop = ListOfPorts([port1, port2, port3])
    return lop