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

tests.unit.v0x04.test_controller2switch.test_multipart_reply   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 29
dl 0
loc 40
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A TestMultipartReply.get_attributes() 0 7 1
A TestMultipartReply.test_pack_unpack_desc() 0 10 1
A TestMultipartReply.setUpClass() 0 9 1
1
"""MultipartReply message test."""
2
3
from pyof.v0x04.controller2switch.common import MultipartType
4
from pyof.v0x04.controller2switch.multipart_reply import (
5
    Desc, MultipartReply, MultipartReplyFlags)
6
from tests.unit.v0x04.test_struct import TestStruct
7
8
9
class TestMultipartReply(TestStruct):
10
    """Test MultipartReply."""
11
12
    @classmethod
13
    def setUpClass(cls):
14
        """Configure raw file and its object in parent class (TestDump)."""
15
        super().setUpClass()
16
        super().set_message(MultipartReply, xid=16,
17
                            multipart_type=MultipartType.OFPMP_METER_CONFIG,
18
                            flags=MultipartReplyFlags.OFPMPF_REPLY_MORE,
19
                            body=b'')
20
        super().set_minimum_size(16)
21
22
    @staticmethod
23
    def get_attributes(multipart_type=MultipartType.OFPMP_DESC,
24
                       flags=MultipartReplyFlags.OFPMPF_REPLY_MORE,
25
                       body=b''):
26
        """Method used to return a dict with instance paramenters."""
27
        return {'xid': 32, 'multipart_type': multipart_type, 'flags': flags,
28
                'body': body}
29
30
    def test_pack_unpack_desc(self):
31
        """Testing multipart_type with OFPMP_DESC."""
32
        instances = Desc(mfr_desc="MANUFACTURER DESCRIPTION",
33
                         hw_desc="HARDWARE DESCRIPTION",
34
                         sw_desc="SOFTWARE DESCRIPTION",
35
                         serial_num="SERIAL NUMBER",
36
                         dp_desc="DATAPATH DESCRIPTION")
37
        options = TestMultipartReply.get_attributes(
38
            multipart_type=MultipartType.OFPMP_DESC, body=instances)
39
        self._test_pack_unpack(**options)
40