Completed
Pull Request — master (#606)
by Gleyberson
02:26
created

TestActionOutput.setUpClass()   A

Complexity

Conditions 1

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
"""Testing Port structures."""
2
from pyof.v0x01.common.action import (
3
    ActionDLAddr, ActionEnqueue, ActionNWAddr, ActionNWTos, ActionOutput,
4
    ActionTPPort, ActionType, ActionVendorHeader, ActionVlanPCP, ActionVlanVid)
5
from pyof.v0x01.common.phy_port import Port
6
from tests.unit.test_struct import TestStruct
7
8
9
class TestActionOutput(TestStruct):
10
    """ActionOutput message tests (also those in :class:`.TestDump`)."""
11
12
    @classmethod
13
    def setUpClass(cls):
14
        """Configure raw file and its object in parent class (TestDump)."""
15
        super().setUpClass()
16
        super().set_raw_dump_file('v0x01', 'ofpt_action_output')
17
        super().set_raw_dump_object(ActionOutput, port=Port.OFPP_CONTROLLER,
18
                                    max_length=8)
19
        super().set_minimum_size(8)
20
21
22
class TestActionEnqueue(TestStruct):
23
    """ActionEnqueue message tests (also those in :class:`.TestDump`)."""
24
25
    @classmethod
26
    def setUpClass(cls):
27
        """Configure raw file and its object in parent class (TestDump)."""
28
        super().setUpClass()
29
        super().set_raw_dump_file('v0x01', 'ofpt_action_enqueue')
30
        super().set_raw_dump_object(ActionEnqueue, port=Port.OFPP_CONTROLLER,
31
                                    queue_id=4)
32
        super().set_minimum_size(16)
33
34
35
class TestActionVlanVid(TestStruct):
36
    """ActionVlanVid message tests (also those in :class:`.TestDump`)."""
37
38
    @classmethod
39
    def setUpClass(cls):
40
        """Configure raw file and its object in parent class (TestDump)."""
41
        super().setUpClass()
42
        super().set_raw_dump_file('v0x01', 'ofpt_action_vlan_vid')
43
        super().set_raw_dump_object(ActionVlanVid, vlan_id=5)
44
        super().set_minimum_size(8)
45
46
47
class TestActionVlanPCP(TestStruct):
48
    """ActionVlanPCP message tests (also those in :class:`.TestDump`)."""
49
50
    @classmethod
51
    def setUpClass(cls):
52
        """Configure raw file and its object in parent class (TestDump)."""
53
        super().setUpClass()
54
        super().set_raw_dump_file('v0x01', 'ofpt_action_vlan_pcp')
55
        super().set_raw_dump_object(ActionVlanPCP, vlan_pcp=2)
56
        super().set_minimum_size(8)
57
58
59
class TestActionDLAddr(TestStruct):
60
    """ActionDLAddr message tests (also those in :class:`.TestDump`)."""
61
62
    @classmethod
63
    def setUpClass(cls):
64
        """Configure raw file and its object in parent class (TestDump)."""
65
        super().setUpClass()
66
        super().set_raw_dump_file('v0x01', 'ofpt_action_dl_addr')
67
        super().set_raw_dump_object(ActionDLAddr,
68
                                    action_type=ActionType.OFPAT_SET_DL_SRC,
69
                                    dl_addr=[12, 12, 12, 12, 12, 12])
70
        super().set_minimum_size(16)
71
72
73
class TestActionNWAddr(TestStruct):
74
    """ActionNWAddr message tests (also those in :class:`.TestDump`)."""
75
76
    @classmethod
77
    def setUpClass(cls):
78
        """Configure raw file and its object in parent class (TestDump)."""
79
        super().setUpClass()
80
        super().set_raw_dump_file('v0x01', 'ofpt_action_nw_addr')
81
        super().set_raw_dump_object(ActionNWAddr,
82
                                    action_type=ActionType.OFPAT_SET_NW_SRC,
83
                                    nw_addr=[12, 12, 12, 12, 12, 12])
84
        super().set_minimum_size(8)
85
86
87
class TestActionNWTos(TestStruct):
88
    """ActionNWTos message tests (also those in :class:`.TestDump`)."""
89
90
    @classmethod
91
    def setUpClass(cls):
92
        """Configure raw file and its object in parent class (TestDump)."""
93
        super().setUpClass()
94
        super().set_raw_dump_file('v0x01', 'ofpt_action_nw_tos')
95
        super().set_raw_dump_object(ActionNWTos,
96
                                    action_type=ActionType.OFPAT_SET_NW_SRC,
97
                                    nw_tos=123456)
98
        super().set_minimum_size(8)
99
100
101
class TestActionTPPort(TestStruct):
102
    """ActionTPPort message tests (also those in :class:`.TestDump`)."""
103
104
    @classmethod
105
    def setUpClass(cls):
106
        """Configure raw file and its object in parent class (TestDump)."""
107
        super().setUpClass()
108
        super().set_raw_dump_file('v0x01', 'ofpt_action_tp_port')
109
        super().set_raw_dump_object(ActionTPPort,
110
                                    action_type=ActionType.OFPAT_SET_TP_SRC,
111
                                    tp_port=8888)
112
        super().set_minimum_size(8)
113
114
115
class TestActionVendorHeader(TestStruct):
116
    """ActionVendorHeader message tests (also those in :class:`.TestDump`)."""
117
118
    @classmethod
119
    def setUpClass(cls):
120
        """Configure raw file and its object in parent class (TestDump)."""
121
        super().setUpClass()
122
        super().set_raw_dump_file('v0x01', 'ofpt_action_vendor_header')
123
        super().set_raw_dump_object(ActionVendorHeader, length=16, vendor=1)
124
        super().set_minimum_size(8)
125