Total Complexity | 2 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | """Testing Error Message.""" |
||
7 | class TestErrorMessage(TestStruct): |
||
8 | """Test the Error Message.""" |
||
9 | |||
10 | @classmethod |
||
11 | def setUpClass(cls): |
||
12 | """Setup TestStruct.""" |
||
13 | super().setUpClass() |
||
14 | super().set_raw_dump_file('v0x01', 'ofpt_error_msg') |
||
15 | super().set_raw_dump_object(ErrorMsg, xid=12, |
||
16 | error_type=ErrorType.OFPET_BAD_REQUEST, |
||
17 | code=BadRequestCode.OFPBRC_BAD_STAT, |
||
18 | data=b'') |
||
19 | super().set_minimum_size(12) |
||
20 | |||
21 | def test_unpack_error_msg(self): |
||
22 | """Test Unpack a sample ErrorMsg.""" |
||
23 | expected = b'\x01\x01\x00\x1b\x00\x00\x00\x18\x00\x03\x00\x02FLOW' |
||
24 | |||
25 | error_msg = ErrorMsg(xid=24, |
||
26 | error_type=ErrorType.OFPET_FLOW_MOD_FAILED, |
||
27 | code=FlowModFailedCode.OFPFMFC_EPERM, |
||
28 | data=b'FLOW') |
||
29 | |||
30 | actual = ErrorMsg(xid=24) |
||
31 | actual.unpack(expected[8:]) |
||
32 | |||
33 | self.assertEqual(actual, error_msg) |
||
34 |