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

Commit 86ed828

Browse files
authored
Merge pull request #312 from cemsbr/fix_v0x04_test
Fix v0x04 pack and unpack test
2 parents 06e4396 + 7b2e3da commit 86ed828

2 files changed

Lines changed: 13 additions & 19 deletions

File tree

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
"""MultipartReply message test."""
22

3-
from pyof.v0x04.controller2switch.common import MeterConfig, MultipartTypes
4-
from pyof.v0x04.controller2switch.meter_mod import (ListOfMeterBandHeader,
5-
MeterBandDrop,
6-
MeterBandDscpRemark)
3+
from pyof.v0x04.controller2switch.common import MultipartTypes
74
from pyof.v0x04.controller2switch.multipart_reply import (MultipartReply,
85
MultipartReplyFlags)
96
from tests.v0x04.test_struct import TestStruct
@@ -19,18 +16,5 @@ def setUpClass(cls):
1916
super().set_message(MultipartReply, xid=16,
2017
multipart_type=MultipartTypes.OFPMP_METER_CONFIG,
2118
flags=MultipartReplyFlags.OFPMPF_REPLY_MORE,
22-
body=cls.meter_config_instance())
19+
body=b'this is a test')
2320
super().set_minimum_size(16)
24-
25-
@classmethod
26-
def meter_config_instance(cls):
27-
"""Method used to create a MeterConfig instance."""
28-
return MeterConfig(bands=cls.list_of_meters())
29-
30-
@staticmethod
31-
def list_of_meters():
32-
"""Instantiate a ListOfMeterBandHeader with some instances."""
33-
meters = [MeterBandDrop(rate=6, burst_size=3),
34-
MeterBandDscpRemark(rate=1, burst_size=4, prec_level=2),
35-
MeterBandDrop(rate=9, burst_size=1)]
36-
return ListOfMeterBandHeader(items=[meters])

tests/v0x04/test_struct.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,18 @@ def set_minimum_size(cls, size):
8484
"""
8585
cls._min_size = size
8686

87-
def _pack_unpack(self, cls, *args, **kwargs):
87+
def test_pack_unpack(self):
8888
"""Pack the message, unpack and check whether they are the same."""
89+
if self._msg_cls:
90+
args, kwargs = self._msg_params
91+
self._test_pack_unpack(self._msg_cls, args, kwargs)
92+
93+
def _test_pack_unpack(self, cls, *args, **kwargs):
94+
"""Pack the message, unpack and check whether they are the same.
95+
96+
Call this method multiple times if you want to test more than one
97+
object.
98+
"""
8999
args, kwargs = self._msg_params
90100
packed = self._msg_cls(*args, **kwargs).pack()
91101
header = Header()

0 commit comments

Comments
 (0)