1
|
|
|
"""Testing FlowMatch structure.""" |
2
|
|
|
import unittest |
3
|
|
|
|
4
|
|
|
from pyof.v0x01.common import flow_match |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
class TestMatch(unittest.TestCase): |
8
|
|
|
"""Test Match structure.""" |
9
|
|
|
|
10
|
|
|
def setUp(self): |
11
|
|
|
"""Basic setup for test.""" |
12
|
|
|
self.message = flow_match.Match() |
13
|
|
|
self.message.in_port = 22 |
14
|
|
|
self.message.dl_src = [1, 2, 3, 4, 5, 6] |
15
|
|
|
self.message.dl_dst = [1, 2, 3, 4, 5, 6] |
16
|
|
|
self.message.dl_vlan = 1 |
17
|
|
|
self.message.dl_vlan_pcp = 1 |
18
|
|
|
self.message.dl_type = 1 |
19
|
|
|
self.message.nw_tos = 1 |
20
|
|
|
self.message.nw_proto = 1 |
21
|
|
|
self.message.nw_src = [192, 168, 0, 1] |
22
|
|
|
self.message.nw_dst = [192, 168, 0, 2] |
23
|
|
|
self.message.tp_src = 22 |
24
|
|
|
self.message.tp_dst = 22 |
25
|
|
|
|
26
|
|
|
def test_get_size(self): |
27
|
|
|
"""[Common/FlowMatch] - size 40.""" |
28
|
|
|
self.assertEqual(self.message.get_size(), 40) |
29
|
|
|
|
30
|
|
|
def test_pack_unpack(self): |
31
|
|
|
"""[Common/FlowMatch] - packing and unpacking.""" |
32
|
|
|
pack = self.message.pack() |
33
|
|
|
unpacked = flow_match.Match() |
34
|
|
|
unpacked.unpack(pack) |
35
|
|
|
self.assertEqual(self.message.pack(), unpacked.pack()) |
36
|
|
|
|
37
|
|
|
@unittest.skip('Not yet implemented') |
38
|
|
|
def test_pack(self): |
39
|
|
|
"""[Common/FlowMatch] - packing.""" |
40
|
|
|
pass |
41
|
|
|
|
42
|
|
|
@unittest.skip('Not yet implemented') |
43
|
|
|
def test_unpack(self): |
44
|
|
|
"""[Common/FlowMatch] - unpacking.""" |
45
|
|
|
pass |
46
|
|
|
|