Test Failed
Pull Request — master (#404)
by
unknown
01:18
created

TestFlowDelete.setUpClass()   A

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
1
"""Flow modification (add/delete) message tests."""
2
from pyof.v0x01.common.action import ActionOutput
3
from pyof.v0x01.common.flow_match import Match
4
from pyof.v0x01.common.phy_port import Port
5
from pyof.v0x01.controller2switch.flow_mod import FlowMod, FlowModCommand
6
from tests.test_struct import TestMsgDumpFile
7
8
9
def _get_flowmod_kwargs(command):
10
    """Return parameters for FlowMod object."""
11
    return {'xid': 4,
12
            'command': command,
13
            'match': _get_match(),
14
            'cookie': 0,
15
            'idle_timeout': 0,
16
            'hard_timeout': 0,
17
            'priority': 32768,
18
            'buffer_id': 4294967295,
19
            'out_port': Port.OFPP_NONE,
20
            'flags': 0,
21
            'actions': _get_actions()}
22
23
24
def _get_match():
25
    """Return a Match object."""
26
    return Match()
27
28
29
def _get_actions():
30
    """Return a List of actions registered by flow object."""
31
    action = ActionOutput(port=65533, max_length=65535)
32
    return [action]
33
34
35
class TestFlowAdd(TestMsgDumpFile):
36
    """Flow addition message tests (also those in :class:`.TestDump`)."""
37
38
    dumpfile = 'v0x01/ofpt_flow_add.dat'
39
    kwargs = _get_flowmod_kwargs(FlowModCommand.OFPFC_ADD)
40
    obj = FlowMod(**kwargs)
41
    min_size = 72
42
43
44
class TestFlowDelete(TestMsgDumpFile):
45
    """Flow deletion message tests (also those in :class:`.TestDump`)."""
46
47
    dumpfile = 'v0x01/ofpt_flow_delete.dat'
48
    kwargs = _get_flowmod_kwargs(FlowModCommand.OFPFC_DELETE)
49
    obj = FlowMod(**kwargs)
50