|
@@ 240-258 (lines=19) @@
|
| 237 |
|
json_response = response.json |
| 238 |
|
assert len(json_response) == 1 |
| 239 |
|
|
| 240 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 241 |
|
def test_flows_counters_bytes(self, mock_from_flow): |
| 242 |
|
"""Test flows_counters function for bytes""" |
| 243 |
|
flow_stats = { |
| 244 |
|
'byte_count': 10, |
| 245 |
|
'duration_sec': 20, |
| 246 |
|
'duration_nsec': 30, |
| 247 |
|
'packet_count': 40 |
| 248 |
|
} |
| 249 |
|
flow_id = '6055f13593fad45e0b4699f49d56b105' |
| 250 |
|
flow_stats_dict_mock = {flow_id: flow_stats} |
| 251 |
|
dpid_id = "00:00:00:00:00:00:00:01" |
| 252 |
|
flow_by_sw = {dpid_id: flow_stats_dict_mock} |
| 253 |
|
mock_from_flow.return_value = flow_by_sw |
| 254 |
|
|
| 255 |
|
with get_controller_mock().api_server.app.app_context(): |
| 256 |
|
response = self.napp.flows_counters('byte_count', dpid_id) |
| 257 |
|
json_response = response.json |
| 258 |
|
assert len(json_response) == 1 |
| 259 |
|
|
| 260 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 261 |
|
def test_flow_stats_by_dpid_flow_id(self, mock_from_flow): |
|
@@ 220-238 (lines=19) @@
|
| 217 |
|
assert json_response[0]["bytes_counter"] == 10 |
| 218 |
|
assert json_response[0]["bits_per_second"] == 4.0 |
| 219 |
|
|
| 220 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 221 |
|
def test_flows_counters_packet(self, mock_from_flow): |
| 222 |
|
"""Test flows_counters function for packet""" |
| 223 |
|
flow_stats = { |
| 224 |
|
'byte_count': 10, |
| 225 |
|
'duration_sec': 20, |
| 226 |
|
'duration_nsec': 30, |
| 227 |
|
'packet_count': 40 |
| 228 |
|
} |
| 229 |
|
flow_id = '6055f13593fad45e0b4699f49d56b105' |
| 230 |
|
flow_stats_dict_mock = {flow_id: flow_stats} |
| 231 |
|
dpid_id = "00:00:00:00:00:00:00:01" |
| 232 |
|
flow_by_sw = {dpid_id: flow_stats_dict_mock} |
| 233 |
|
mock_from_flow.return_value = flow_by_sw |
| 234 |
|
|
| 235 |
|
with get_controller_mock().api_server.app.app_context(): |
| 236 |
|
response = self.napp.flows_counters('packet_count', dpid_id) |
| 237 |
|
json_response = response.json |
| 238 |
|
assert len(json_response) == 1 |
| 239 |
|
|
| 240 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 241 |
|
def test_flows_counters_bytes(self, mock_from_flow): |