|
@@ 260-280 (lines=21) @@
|
| 257 |
|
assert response.json == expected |
| 258 |
|
assert response.status_code == 200 |
| 259 |
|
|
| 260 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 261 |
|
def test_flow_stats_by_dpid_flow_id_with_dpid(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 = "/v1/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 |
|
def _patch_switch_flow(self, flow_id): |
| 283 |
|
"""Helper method to patch controller to return switch/flow data.""" |
|
@@ 238-258 (lines=21) @@
|
| 235 |
|
assert json_response[0]["bytes_counter"] == 10 |
| 236 |
|
assert json_response[0]["bits_per_second"] == 4.0 |
| 237 |
|
|
| 238 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 239 |
|
def test_flow_stats_by_dpid_flow_id(self, mock_from_flow): |
| 240 |
|
"""Test flow_stats rest call.""" |
| 241 |
|
flow_stats = { |
| 242 |
|
'byte_count': 148, |
| 243 |
|
'duration_sec': 1589, |
| 244 |
|
'duration_nsec': 556000000, |
| 245 |
|
'packet_count': 2 |
| 246 |
|
} |
| 247 |
|
flow_stats_dict_mock = {'6055f13593fad45e0b4699f49d56b105': flow_stats} |
| 248 |
|
flow_by_sw = {"00:00:00:00:00:00:00:01": flow_stats_dict_mock} |
| 249 |
|
mock_from_flow.return_value = flow_by_sw |
| 250 |
|
|
| 251 |
|
api = get_test_client(self.napp.controller, self.napp) |
| 252 |
|
endpoint = "/v1/flow/stats?dpid=00:00:00:00:00:00:00:01" |
| 253 |
|
url = f"{self.server_name_url}"+endpoint |
| 254 |
|
|
| 255 |
|
response = api.get(url) |
| 256 |
|
expected = flow_by_sw |
| 257 |
|
assert response.json == expected |
| 258 |
|
assert response.status_code == 200 |
| 259 |
|
|
| 260 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 261 |
|
def test_flow_stats_by_dpid_flow_id_with_dpid(self, mock_from_flow): |