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
|
"""MultipartRequest message test."""
from pyof.v0x04.controller2switch.multipart_request import (
MultipartRequest, MultipartRequestFlags, MultipartType, PortStatsRequest,
TableFeatures)
from tests.unit.v0x04.test_struct import TestStruct
class TestMultipartRequest(TestStruct):
"""Test the MultipartRequest message."""
@classmethod
def setUpClass(cls):
"""Configure raw file and its object in parent class (TestDump)."""
super().setUpClass()
super().set_message(MultipartRequest, xid=16,
multipart_type=MultipartType.OFPMP_TABLE_FEATURES,
flags=MultipartRequestFlags.OFPMPF_REQ_MORE,
body=b'')
super().set_minimum_size(16)
@staticmethod
def get_attributes(multipart_type=MultipartType.OFPMP_DESC,
flags=MultipartRequestFlags.OFPMPF_REQ_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."""
options = TestMultipartRequest.get_attributes(
multipart_type=MultipartType.OFPMP_DESC)
self._test_pack_unpack(**options)
def test_pack_unpack_table(self):
"""Testing multipart_type with OFPMP_TABLE."""
options = TestMultipartRequest.get_attributes(
multipart_type=MultipartType.OFPMP_TABLE)
self._test_pack_unpack(**options)
def test_pack_unpack__port_stats_request(self):
"""Testing multipart_type with OFPMP_PORT_STATS."""
options = TestMultipartRequest.get_attributes(
multipart_type=MultipartType.OFPMP_PORT_STATS,
body=PortStatsRequest(port_no=33))
self._test_pack_unpack(**options)
def test_pack_unpack_port_desc(self):
"""Testing multipart_type with OFPMP_PORT_DESC."""
options = TestMultipartRequest.get_attributes(
multipart_type=MultipartType.OFPMP_PORT_DESC)
self._test_pack_unpack(**options)
def test_pack_unpack_table_features(self):
"""Testing multipart_type with OFPMP_TABLE_FEATURES."""
instance = [TableFeatures(table_id=2),
TableFeatures(table_id=6),
TableFeatures(table_id=4)]
options = TestMultipartRequest.get_attributes(
multipart_type=MultipartType.OFPMP_TABLE_FEATURES,
body=instance)
self._test_pack_unpack(**options)
|