File: test_flow_match.py

package info (click to toggle)
python-openflow 2021.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,224 kB
  • sloc: python: 6,906; sh: 4; makefile: 4
file content (45 lines) | stat: -rw-r--r-- 1,363 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""Testing FlowMatch structure."""
import unittest

from pyof.v0x01.common import flow_match


class TestMatch(unittest.TestCase):
    """Test Match structure."""

    def setUp(self):
        """Basic setup for test."""
        self.message = flow_match.Match()
        self.message.in_port = 22
        self.message.dl_src = [1, 2, 3, 4, 5, 6]
        self.message.dl_dst = [1, 2, 3, 4, 5, 6]
        self.message.dl_vlan = 1
        self.message.dl_vlan_pcp = 1
        self.message.dl_type = 1
        self.message.nw_tos = 1
        self.message.nw_proto = 1
        self.message.nw_src = [192, 168, 0, 1]
        self.message.nw_dst = [192, 168, 0, 2]
        self.message.tp_src = 22
        self.message.tp_dst = 22

    def test_get_size(self):
        """[Common/FlowMatch] - size 40."""
        self.assertEqual(self.message.get_size(), 40)

    def test_pack_unpack(self):
        """[Common/FlowMatch] - packing and unpacking."""
        pack = self.message.pack()
        unpacked = flow_match.Match()
        unpacked.unpack(pack)
        self.assertEqual(self.message.pack(), unpacked.pack())

    @unittest.skip('Not yet implemented')
    def test_pack(self):
        """[Common/FlowMatch] - packing."""
        pass

    @unittest.skip('Not yet implemented')
    def test_unpack(self):
        """[Common/FlowMatch] - unpacking."""
        pass