Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit deb35e3

Browse files
committed
Fixing old tests
1 parent 959857d commit deb35e3

6 files changed

Lines changed: 27 additions & 122 deletions

File tree

tests/v0x04/test_common/test_table_feature.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

tests/v0x04/test_controller2switch/test_meter_features.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/v0x04/test_controller2switch/test_meter_stats.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

tests/v0x04/test_controller2switch/test_multipart_reply.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from tests.v0x04.test_struct import TestStruct
88

99

10-
class TestTableFeatures(TestStruct):
11-
"""Test TableFeatures."""
10+
class TestMultipartReply(TestStruct):
11+
"""Test MultipartReply."""
1212

1313
@classmethod
1414
def setUpClass(cls):
@@ -17,5 +17,5 @@ def setUpClass(cls):
1717
super().set_message(MultipartReply, xid=16,
1818
multipart_type=MultipartTypes.OFPMP_METER_CONFIG,
1919
flags=MultipartReplyFlags.OFPMPF_REPLY_MORE,
20-
body=b'this is a test')
20+
body='')
2121
super().set_minimum_size(16)
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""MultipartRequest message test."""
2-
from pyof.v0x04.controller2switch.multipart_request import MultipartRequest
2+
from pyof.v0x04.controller2switch.multipart_request import (
3+
MultipartRequest, MultipartRequestFlags, MultipartTypes, TableFeatures)
34

4-
from tests.test_struct import TestStruct
5+
from tests.v0x04.test_struct import TestStruct
56

67

78
class TestMultipartRequest(TestStruct):
@@ -11,7 +12,21 @@ class TestMultipartRequest(TestStruct):
1112
def setUpClass(cls):
1213
"""Configure raw file and its object in parent class (TestDump)."""
1314
super().setUpClass()
14-
super().set_raw_dump_file('v0x04', 'ofpt_multipart_request')
15-
super().set_raw_dump_object(MultipartRequest, xid=3, multipart_type=0,
16-
flags=1, body=0)
15+
16+
super().set_message(MultipartRequest, xid=16,
17+
multipart_type=MultipartTypes.OFPMP_TABLE_FEATURES,
18+
flags=MultipartRequestFlags.OFPMPF_REQ_MORE,
19+
body=b'')
1720
super().set_minimum_size(16)
21+
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)]
27+
28+
options = {'xid': 16,
29+
'multipart_type': MultipartTypes.OFPMP_TABLE_FEATURES,
30+
'flags': MultipartRequestFlags.OFPMPF_REQ_MORE,
31+
'body': table_features}
32+
self._test_pack_unpack(**options)

tests/v0x04/test_struct.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ def test_pack_unpack(self):
8888
"""Pack the message, unpack and check whether they are the same."""
8989
if self._msg_cls:
9090
args, kwargs = self._msg_params
91-
self._test_pack_unpack(self._msg_cls, args, kwargs)
91+
self._test_pack_unpack(*args, **kwargs)
9292

93-
def _test_pack_unpack(self, cls, *args, **kwargs):
93+
def _test_pack_unpack(self, *args, **kwargs):
9494
"""Pack the message, unpack and check whether they are the same.
9595
9696
Call this method multiple times if you want to test more than one
9797
object.
9898
"""
99-
args, kwargs = self._msg_params
100-
packed = self._msg_cls(*args, **kwargs).pack()
99+
obj = self._msg_cls(*args, **kwargs)
100+
packed = obj.pack()
101101
header = Header()
102102
header_size = header.get_size()
103103
header.unpack(packed[:header_size])

0 commit comments

Comments
 (0)