| Total Complexity | 2 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | """Test for PortStats structure.""" |
||
| 2 | from pyof.v0x01.controller2switch.common import PortStats, StatsType |
||
| 3 | from pyof.v0x01.controller2switch.stats_reply import StatsReply |
||
| 4 | from tests.unit.test_struct import TestStruct |
||
| 5 | |||
| 6 | |||
| 7 | class TestPortStats(TestStruct): |
||
| 8 | """Test for PortStats structure.""" |
||
| 9 | |||
| 10 | @classmethod |
||
| 11 | def setUpClass(cls): |
||
| 12 | """[Controller2Switch/PortStats] - size 104.""" |
||
| 13 | super().setUpClass() |
||
| 14 | super().set_raw_dump_file('v0x01', 'ofpt_port_stats') |
||
| 15 | super().set_raw_dump_object(StatsReply, xid=13, |
||
| 16 | body_type=StatsType.OFPST_PORT, |
||
| 17 | flags=0, body=_get_port_stats()) |
||
| 18 | super().set_minimum_size(12) |
||
| 19 | |||
| 20 | |||
| 21 | def _get_port_stats(): |
||
| 22 | """Function used to return a PortStats instance.""" |
||
| 23 | return PortStats(port_no=80, rx_packets=5, tx_packets=10, |
||
| 24 | rx_bytes=200, tx_bytes=400, rx_dropped=0, |
||
| 25 | tx_dropped=0, rx_errors=0, tx_errors=0, |
||
| 26 | rx_frame_err=0, rx_over_err=0, |
||
| 27 | rx_crc_err=0, collisions=0) |
||
| 28 |