|
@@ 282-302 (lines=21) @@
|
| 279 |
|
assert response.json == expected |
| 280 |
|
assert response.status_code == 200 |
| 281 |
|
|
| 282 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 283 |
|
def test_flow_stats_by_dpid_flow_id_with_dpid(self, mock_from_flow): |
| 284 |
|
"""Test flow_stats rest call.""" |
| 285 |
|
flow_stats = { |
| 286 |
|
'byte_count': 148, |
| 287 |
|
'duration_sec': 1589, |
| 288 |
|
'duration_nsec': 556000000, |
| 289 |
|
'packet_count': 2 |
| 290 |
|
} |
| 291 |
|
flow_stats_dict_mock = {'6055f13593fad45e0b4699f49d56b105': flow_stats} |
| 292 |
|
flow_by_sw = {"00:00:00:00:00:00:00:01": flow_stats_dict_mock} |
| 293 |
|
mock_from_flow.return_value = flow_by_sw |
| 294 |
|
|
| 295 |
|
api = get_test_client(self.napp.controller, self.napp) |
| 296 |
|
endpoint = "/flow/stats?dpid=00:00:00:00:00:00:00:01" |
| 297 |
|
url = f"{self.server_name_url}"+endpoint |
| 298 |
|
|
| 299 |
|
response = api.get(url) |
| 300 |
|
expected = flow_by_sw |
| 301 |
|
assert response.json == expected |
| 302 |
|
assert response.status_code == 200 |
| 303 |
|
|
| 304 |
|
def _patch_switch_flow(self, flow_id): |
| 305 |
|
"""Helper method to patch controller to return switch/flow data.""" |
|
@@ 260-280 (lines=21) @@
|
| 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): |
| 262 |
|
"""Test flow_stats rest call.""" |
| 263 |
|
flow_stats = { |
| 264 |
|
'byte_count': 148, |
| 265 |
|
'duration_sec': 1589, |
| 266 |
|
'duration_nsec': 556000000, |
| 267 |
|
'packet_count': 2 |
| 268 |
|
} |
| 269 |
|
flow_stats_dict_mock = {'6055f13593fad45e0b4699f49d56b105': flow_stats} |
| 270 |
|
flow_by_sw = {"00:00:00:00:00:00:00:01": flow_stats_dict_mock} |
| 271 |
|
mock_from_flow.return_value = flow_by_sw |
| 272 |
|
|
| 273 |
|
api = get_test_client(self.napp.controller, self.napp) |
| 274 |
|
endpoint = "/flow/stats?dpid=00:00:00:00:00:00:00:01" |
| 275 |
|
url = f"{self.server_name_url}"+endpoint |
| 276 |
|
|
| 277 |
|
response = api.get(url) |
| 278 |
|
expected = flow_by_sw |
| 279 |
|
assert response.json == expected |
| 280 |
|
assert response.status_code == 200 |
| 281 |
|
|
| 282 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 283 |
|
def test_flow_stats_by_dpid_flow_id_with_dpid(self, mock_from_flow): |