@@ 312-330 (lines=19) @@ | ||
309 | assert response.status_code == 200 |
|
310 | assert len(response.json()) == 0 |
|
311 | ||
312 | @patch("napps.amlight.kytos_stats.main.Main.table_stats_by_dpid_table_id") |
|
313 | async def test_table_stats_by_dpid_table_id(self, mock_from_table): |
|
314 | """Test table_stats rest call.""" |
|
315 | table_info = { |
|
316 | "table_id": 10, |
|
317 | "active_count": 20, |
|
318 | "lookup_count": 30, |
|
319 | "matched_count": 32768 |
|
320 | } |
|
321 | table_stats_dict_mock = {'10': table_info} |
|
322 | table_by_sw = {"00:00:00:00:00:00:00:01": table_stats_dict_mock} |
|
323 | mock_from_table.return_value = table_by_sw |
|
324 | ||
325 | endpoint = "/table/stats?dpid=00:00:00:00:00:00:00:01&table=10" |
|
326 | url = f"{self.base_endpoint}{endpoint}" |
|
327 | response = await self.api_client.get(url) |
|
328 | assert response.status_code == 200 |
|
329 | expected = table_by_sw |
|
330 | assert response.json() == expected |
|
331 | ||
332 | async def test_port_stats_filter(self): |
|
333 | """Test table_stats rest call.""" |
|
@@ 425-445 (lines=21) @@ | ||
422 | ||
423 | assert self.napp.port_stats_dict == expected_dict |
|
424 | ||
425 | @patch("napps.amlight.kytos_stats.main.Main.table_stats_by_dpid_table_id") |
|
426 | async def test_table_stats_by_dpid_table_id_without_dpid(self, |
|
427 | mock_from_table): |
|
428 | """Test table_stats rest call.""" |
|
429 | table_info = { |
|
430 | "table_id": 10, |
|
431 | "active_count": 20, |
|
432 | "lookup_count": 30, |
|
433 | "matched_count": 32768 |
|
434 | } |
|
435 | table_stats_dict_mock = {'10': table_info} |
|
436 | table_by_sw = {"00:00:00:00:00:00:00:01": table_stats_dict_mock} |
|
437 | mock_from_table.return_value = table_by_sw |
|
438 | ||
439 | endpoint = "/table/stats" |
|
440 | url = f"{self.base_endpoint}{endpoint}" |
|
441 | response = await self.api_client.get(url) |
|
442 | assert response.status_code == 200 |
|
443 | ||
444 | expected = table_by_sw |
|
445 | assert response.json() == expected |
|
446 | ||
447 | @patch("napps.amlight.kytos_stats.main.Main.table_stats_by_dpid_table_id") |
|
448 | async def test_table_stats_by_dpid_table_id_not_found(self, |