File: test_multipart_reply.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 (39 lines) | stat: -rw-r--r-- 1,656 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
"""MultipartReply message test."""

from pyof.v0x04.controller2switch.common import MultipartType
from pyof.v0x04.controller2switch.multipart_reply import (
    Desc, MultipartReply, MultipartReplyFlags)
from tests.unit.v0x04.test_struct import TestStruct


class TestMultipartReply(TestStruct):
    """Test MultipartReply."""

    @classmethod
    def setUpClass(cls):
        """Configure raw file and its object in parent class (TestDump)."""
        super().setUpClass()
        super().set_message(MultipartReply, xid=16,
                            multipart_type=MultipartType.OFPMP_METER_CONFIG,
                            flags=MultipartReplyFlags.OFPMPF_REPLY_MORE,
                            body=b'')
        super().set_minimum_size(16)

    @staticmethod
    def get_attributes(multipart_type=MultipartType.OFPMP_DESC,
                       flags=MultipartReplyFlags.OFPMPF_REPLY_MORE,
                       body=b''):
        """Method used to return a dict with instance paramenters."""
        return {'xid': 32, 'multipart_type': multipart_type, 'flags': flags,
                'body': body}

    def test_pack_unpack_desc(self):
        """Testing multipart_type with OFPMP_DESC."""
        instances = Desc(mfr_desc="MANUFACTURER DESCRIPTION",
                         hw_desc="HARDWARE DESCRIPTION",
                         sw_desc="SOFTWARE DESCRIPTION",
                         serial_num="SERIAL NUMBER",
                         dp_desc="DATAPATH DESCRIPTION")
        options = TestMultipartReply.get_attributes(
            multipart_type=MultipartType.OFPMP_DESC, body=instances)
        self._test_pack_unpack(**options)