Passed
Pull Request — master (#374)
by macartur
02:21
created

TestErrorMessage   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

2 Methods

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