Test Failed
Push — master ( 182015...f7f025 )
by Carlos Eduardo
01:35
created

test_pack_unpack_table_features()   A

Complexity

Conditions 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
1
"""MultipartRequest message test."""
2
from pyof.v0x04.controller2switch.multipart_request import (
3
    MultipartRequest, MultipartRequestFlags, MultipartTypes,
4
    PortStatsRequest, TableFeatures)
5
6
from tests.v0x04.test_struct import TestStruct
7
8
9
class TestMultipartRequest(TestStruct):
10
    """Test the MultipartRequest message."""
11
12
    @classmethod
13
    def setUpClass(cls):
14
        """Configure raw file and its object in parent class (TestDump)."""
15
        super().setUpClass()
16
17
        super().set_message(MultipartRequest, xid=16,
18
                            multipart_type=MultipartTypes.OFPMP_TABLE_FEATURES,
19
                            flags=MultipartRequestFlags.OFPMPF_REQ_MORE,
20
                            body=b'')
21
        super().set_minimum_size(16)
22
23
    @staticmethod
24
    def get_attributes(multipart_type=MultipartTypes.OFPMP_DESC,
25
                       flags=MultipartRequestFlags.OFPMPF_REQ_MORE,
26
                       body=''):
27
        """Method used to return a dict with instance paramenters."""
28
        return {'xid': 32, 'multipart_type': multipart_type, 'flags': flags,
29
                'body': body}
30
31
    def test_pack_unpack_desc(self):
32
        """Testing multipart_type with OFPMP_DESC."""
33
        options = TestMultipartRequest.get_attributes(
34
            multipart_type=MultipartTypes.OFPMP_DESC)
35
        self._test_pack_unpack(**options)
36
37
    def test_pack_unpack_table(self):
38
        """Testing multipart_type with OFPMP_TABLE."""
39
        options = TestMultipartRequest.get_attributes(
40
            multipart_type=MultipartTypes.OFPMP_TABLE)
41
        self._test_pack_unpack(**options)
42
43
    def test_pack_unpack__port_stats_request(self):
44
        """Testing multipart_type with OFPMP_PORT_STATS."""
45
        options = TestMultipartRequest.get_attributes(
46
            multipart_type=MultipartTypes.OFPMP_PORT_STATS,
47
            body=PortStatsRequest(port_no=33))
48
        self._test_pack_unpack(**options)
49
50
    def test_pack_unpack_port_desc(self):
51
        """Testing multipart_type with OFPMP_PORT_DESC."""
52
        options = TestMultipartRequest.get_attributes(
53
            multipart_type=MultipartTypes.OFPMP_PORT_DESC)
54
        self._test_pack_unpack(**options)
55
56
    def test_pack_unpack_table_features(self):
57
        """Testing multipart_type with OFPMP_TABLE_FEATURES."""
58
        instance = [TableFeatures(table_id=2),
59
                    TableFeatures(table_id=6),
60
                    TableFeatures(table_id=4)]
61
        options = TestMultipartRequest.get_attributes(
62
            multipart_type=MultipartTypes.OFPMP_TABLE_FEATURES,
63
            body=instance)
64
        self._test_pack_unpack(**options)
65