File: test_flow_stats_request.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 (33 lines) | stat: -rw-r--r-- 1,280 bytes parent folder | download
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
"""Test FlowStatsRequest message."""
from pyof.v0x01.common.flow_match import Match
from pyof.v0x01.controller2switch.common import FlowStatsRequest, StatsType
from pyof.v0x01.controller2switch.stats_request import StatsRequest
from tests.unit.test_struct import TestStruct


class TestFlowStatsRequest(TestStruct):
    """Test class for TestFlowStatsRequest."""

    @classmethod
    def setUpClass(cls):
        """[Controller2Switch/FlowStatsRequest] - size 44."""
        super().setUpClass()
        super().set_raw_dump_file('v0x01', 'ofpt_flow_stats_request')
        super().set_raw_dump_object(StatsRequest, xid=12,
                                    body_type=StatsType.OFPST_FLOW,
                                    flags=0, body=_get_flow_stats_request())
        super().set_minimum_size(12)


def _get_flow_stats_request():
    return FlowStatsRequest(match=_get_match(), table_id=1, out_port=80)


def _get_match():
    """Function used to return a Match instance."""
    return Match(in_port=80, dl_src='01:02:03:04:05:06',
                 dl_dst='01:02:03:04:05:06', dl_vlan=1,
                 dl_vlan_pcp=1, dl_type=1,
                 nw_tos=1, nw_proto=1,
                 nw_src='192.168.0.1', nw_dst='192.168.0.1',
                 tp_src=80, tp_dst=80)