|
@@ 96-109 (lines=14) @@
|
| 93 |
|
assert response.status_code == 404 |
| 94 |
|
assert response.json()["description"] == "Flow does not exist" |
| 95 |
|
|
| 96 |
|
@patch("napps.amlight.kytos_stats.main.Main.flow_from_id") |
| 97 |
|
async def test_bytes_count(self, mock_from_flow): |
| 98 |
|
"""Test bytes_count rest call.""" |
| 99 |
|
flow_id = '1' |
| 100 |
|
mock_from_flow.return_value = self._get_mocked_flow_base() |
| 101 |
|
self._patch_switch_flow(flow_id) |
| 102 |
|
|
| 103 |
|
endpoint = f"{self.base_endpoint}/bytes_count/{flow_id}" |
| 104 |
|
response = await self.api_client.get(endpoint) |
| 105 |
|
assert response.status_code == 200 |
| 106 |
|
json_response = response.json() |
| 107 |
|
assert json_response["flow_id"] == flow_id |
| 108 |
|
assert json_response["bytes_counter"] == 10 |
| 109 |
|
assert json_response["bits_per_second"] == 4.0 |
| 110 |
|
|
| 111 |
|
async def test_packet_count_per_flow_empty(self): |
| 112 |
|
"""Test packet_count rest call with a flow that does not exist .""" |
|
@@ 73-86 (lines=14) @@
|
| 70 |
|
assert response.status_code == 404 |
| 71 |
|
assert response.json()["description"] == "Flow does not exist" |
| 72 |
|
|
| 73 |
|
@patch("napps.amlight.kytos_stats.main.Main.flow_from_id") |
| 74 |
|
async def test_packet_count(self, mock_from_flow): |
| 75 |
|
"""Test packet_count rest call.""" |
| 76 |
|
flow_id = '1' |
| 77 |
|
mock_from_flow.return_value = self._get_mocked_flow_base() |
| 78 |
|
|
| 79 |
|
self._patch_switch_flow(flow_id) |
| 80 |
|
endpoint = f"{self.base_endpoint}/packet_count/{flow_id}" |
| 81 |
|
response = await self.api_client.get(endpoint) |
| 82 |
|
assert response.status_code == 200 |
| 83 |
|
json_response = response.json() |
| 84 |
|
assert json_response["flow_id"] == flow_id |
| 85 |
|
assert json_response["packet_counter"] == 40 |
| 86 |
|
assert json_response["packet_per_second"] == 2.0 |
| 87 |
|
|
| 88 |
|
async def test_bytes_count_not_found(self): |
| 89 |
|
"""Test bytes_count rest call with wrong flow_id.""" |