11"""MultipartRequest message test."""
22from pyof .v0x04 .controller2switch .multipart_request import (
3- MultipartRequest , MultipartRequestFlags , MultipartTypes , TableFeatures )
3+ MultipartRequest , MultipartRequestFlags , MultipartTypes ,
4+ PortStatsRequest , TableFeatures )
45
56from tests .v0x04 .test_struct import TestStruct
67
@@ -19,14 +20,45 @@ def setUpClass(cls):
1920 body = b'' )
2021 super ().set_minimum_size (16 )
2122
22- def test_body_table_features (self ):
23- """Method to test pack and unpack using table_features as body."""
24- table_features = [TableFeatures (table_id = 2 ),
25- TableFeatures (table_id = 6 ),
26- TableFeatures (table_id = 4 )]
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 }
2730
28- options = {'xid' : 16 ,
29- 'multipart_type' : MultipartTypes .OFPMP_TABLE_FEATURES ,
30- 'flags' : MultipartRequestFlags .OFPMPF_REQ_MORE ,
31- 'body' : table_features }
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 )
3264 self ._test_pack_unpack (** options )
0 commit comments