Passed
Pull Request — master (#368)
by macartur
02:11
created

TestErrorMessage   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_unpack_error_msg() 0 13 1
A setUpClass() 0 11 1
1
"""Testing Error Message."""
2
from pyof.v0x01.asynchronous.error_msg import (BadRequestCode, ErrorMsg,
3
                                               ErrorType, FlowModFailedCode)
4
5
from tests.test_struct import TestStruct
6
7
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