Passed
Pull Request — master (#404)
by
unknown
01:47
created

TestIPV4   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A test_IPv4_checksum() 0 3 1
1
"""Test Python-openflow network types."""
2
from pyof.foundation.basic_types import BinaryData
3
from pyof.foundation.network_types import GenericTLV, IPv4
4
from tests.test_struct import TestStructDump
5
6
7
class TestGenericTLV(TestStructDump):
8
    """Test the GenericTLV value data."""
9
10
    dump = b'\xfe\x04test'
11
    obj = GenericTLV(value=BinaryData(b'test'))
12
13
14
class TestIPV4(TestStructDump):
15
    """Test the IPV4 class."""
16
17
    dump = b'F(\x00 \x00\x00\x00\x00@\x11\x02' +\
18
        b'\xc5\xc0\xa8\x00\n\xac\x10\n\x1e1000testdata'
19
    obj = IPv4(dscp=10, ttl=64, protocol=17, source="192.168.0.10",
20
               destination="172.16.10.30", options=b'1000',
21
               data=b'testdata')
22
23
    def test_IPv4_checksum(self):
24
        """Test if the IPv4 checksum is being calculated correclty."""
25
        self.assertEqual(self._unpacked_dump.checksum, 709)
26