File: test_action.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 (124 lines) | stat: -rw-r--r-- 4,790 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
"""Testing Port structures."""
from pyof.v0x01.common.action import (
    ActionDLAddr, ActionEnqueue, ActionNWAddr, ActionNWTos, ActionOutput,
    ActionTPPort, ActionType, ActionVendorHeader, ActionVlanPCP, ActionVlanVid)
from pyof.v0x01.common.phy_port import Port
from tests.unit.test_struct import TestStruct


class TestActionOutput(TestStruct):
    """ActionOutput message tests (also those in :class:`.TestDump`)."""

    @classmethod
    def setUpClass(cls):
        """Configure raw file and its object in parent class (TestDump)."""
        super().setUpClass()
        super().set_raw_dump_file('v0x01', 'ofpt_action_output')
        super().set_raw_dump_object(ActionOutput, port=Port.OFPP_CONTROLLER,
                                    max_length=8)
        super().set_minimum_size(8)


class TestActionEnqueue(TestStruct):
    """ActionEnqueue message tests (also those in :class:`.TestDump`)."""

    @classmethod
    def setUpClass(cls):
        """Configure raw file and its object in parent class (TestDump)."""
        super().setUpClass()
        super().set_raw_dump_file('v0x01', 'ofpt_action_enqueue')
        super().set_raw_dump_object(ActionEnqueue, port=Port.OFPP_CONTROLLER,
                                    queue_id=4)
        super().set_minimum_size(16)


class TestActionVlanVid(TestStruct):
    """ActionVlanVid message tests (also those in :class:`.TestDump`)."""

    @classmethod
    def setUpClass(cls):
        """Configure raw file and its object in parent class (TestDump)."""
        super().setUpClass()
        super().set_raw_dump_file('v0x01', 'ofpt_action_vlan_vid')
        super().set_raw_dump_object(ActionVlanVid, vlan_id=5)
        super().set_minimum_size(8)


class TestActionVlanPCP(TestStruct):
    """ActionVlanPCP message tests (also those in :class:`.TestDump`)."""

    @classmethod
    def setUpClass(cls):
        """Configure raw file and its object in parent class (TestDump)."""
        super().setUpClass()
        super().set_raw_dump_file('v0x01', 'ofpt_action_vlan_pcp')
        super().set_raw_dump_object(ActionVlanPCP, vlan_pcp=2)
        super().set_minimum_size(8)


class TestActionDLAddr(TestStruct):
    """ActionDLAddr message tests (also those in :class:`.TestDump`)."""

    @classmethod
    def setUpClass(cls):
        """Configure raw file and its object in parent class (TestDump)."""
        super().setUpClass()
        super().set_raw_dump_file('v0x01', 'ofpt_action_dl_addr')
        super().set_raw_dump_object(ActionDLAddr,
                                    action_type=ActionType.OFPAT_SET_DL_SRC,
                                    dl_addr=[12, 12, 12, 12, 12, 12])
        super().set_minimum_size(16)


class TestActionNWAddr(TestStruct):
    """ActionNWAddr message tests (also those in :class:`.TestDump`)."""

    @classmethod
    def setUpClass(cls):
        """Configure raw file and its object in parent class (TestDump)."""
        super().setUpClass()
        super().set_raw_dump_file('v0x01', 'ofpt_action_nw_addr')
        super().set_raw_dump_object(ActionNWAddr,
                                    action_type=ActionType.OFPAT_SET_NW_SRC,
                                    nw_addr=[12, 12, 12, 12, 12, 12])
        super().set_minimum_size(8)


class TestActionNWTos(TestStruct):
    """ActionNWTos message tests (also those in :class:`.TestDump`)."""

    @classmethod
    def setUpClass(cls):
        """Configure raw file and its object in parent class (TestDump)."""
        super().setUpClass()
        super().set_raw_dump_file('v0x01', 'ofpt_action_nw_tos')
        super().set_raw_dump_object(ActionNWTos,
                                    action_type=ActionType.OFPAT_SET_NW_SRC,
                                    nw_tos=123456)
        super().set_minimum_size(8)


class TestActionTPPort(TestStruct):
    """ActionTPPort message tests (also those in :class:`.TestDump`)."""

    @classmethod
    def setUpClass(cls):
        """Configure raw file and its object in parent class (TestDump)."""
        super().setUpClass()
        super().set_raw_dump_file('v0x01', 'ofpt_action_tp_port')
        super().set_raw_dump_object(ActionTPPort,
                                    action_type=ActionType.OFPAT_SET_TP_SRC,
                                    tp_port=8888)
        super().set_minimum_size(8)


class TestActionVendorHeader(TestStruct):
    """ActionVendorHeader message tests (also those in :class:`.TestDump`)."""

    @classmethod
    def setUpClass(cls):
        """Configure raw file and its object in parent class (TestDump)."""
        super().setUpClass()
        super().set_raw_dump_file('v0x01', 'ofpt_action_vendor_header')
        super().set_raw_dump_object(ActionVendorHeader, length=16, vendor=1)
        super().set_minimum_size(8)