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