| Total Complexity | 4 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | """Testing v0x04 error message class.""" |
||
| 2 | from pyof.foundation.exceptions import MethodNotImplemented |
||
| 3 | from pyof.v0x04.asynchronous.error_msg import ( |
||
| 4 | ErrorExperimenterMsg, ErrorMsg, ErrorType, MeterModFailedCode) |
||
| 5 | from tests.unit.test_struct import TestStruct |
||
| 6 | |||
| 7 | |||
| 8 | class TestErrorMsg(TestStruct): |
||
| 9 | """ErroMsg message tests (also those in :class:`.TestDump`).""" |
||
| 10 | |||
| 11 | @classmethod |
||
| 12 | def setUpClass(cls): |
||
| 13 | """Configure raw file and its object in parent class (TestDump).""" |
||
| 14 | error_type = ErrorType.OFPET_METER_MOD_FAILED |
||
| 15 | code = MeterModFailedCode.OFPMMFC_UNKNOWN_METER |
||
| 16 | super().setUpClass() |
||
| 17 | super().set_raw_dump_file('v0x04', 'ofpt_error') |
||
| 18 | super().set_raw_dump_object(ErrorMsg, xid=1, error_type=error_type, |
||
| 19 | code=code, data=_get_data()) |
||
| 20 | super().set_minimum_size(12) |
||
| 21 | |||
| 22 | @staticmethod |
||
| 23 | def test_unpack(): |
||
| 24 | """[Asynchronous/error_msg] - unpack ErrorExperimenterMsg.""" |
||
| 25 | unpacked = ErrorExperimenterMsg() |
||
| 26 | try: |
||
| 27 | unpacked.unpack("pack") |
||
| 28 | except MethodNotImplemented: |
||
| 29 | pass |
||
| 30 | |||
| 31 | |||
| 32 | def _get_data(): |
||
| 33 | """Return data for ErrorMsg object.""" |
||
| 34 | data = b'\x04\x12\x00\x18\x00\x00\x00\x01\x00\x0a\x00\x00\x00\x00\x00' |
||
| 35 | data += b'\x00\x00\x00\x00\x01\x00\x00\x00\x00' |
||
| 36 | return data |
||
| 37 |