Code Duplication    Length = 19-21 lines in 2 locations

tests/unit/test_main.py 2 locations

@@ 413-433 (lines=21) @@
410
411
        assert self.napp.port_stats_dict == expected_dict
412
413
    @patch("napps.amlight.kytos_stats.main.Main.table_stats_by_dpid_table_id")
414
    async def test_table_stats_by_dpid_table_id_without_dpid(self,
415
                                                             mock_from_table):
416
        """Test table_stats rest call."""
417
        table_info = {
418
            "table_id": 10,
419
            "active_count": 20,
420
            "lookup_count": 30,
421
            "matched_count": 32768
422
            }
423
        table_stats_dict_mock = {'10': table_info}
424
        table_by_sw = {"00:00:00:00:00:00:00:01": table_stats_dict_mock}
425
        mock_from_table.return_value = table_by_sw
426
427
        endpoint = "/table/stats"
428
        url = f"{self.base_endpoint}{endpoint}"
429
        response = await self.api_client.get(url)
430
        assert response.status_code == 200
431
432
        expected = table_by_sw
433
        assert response.json() == expected
434
435
    @patch("napps.amlight.kytos_stats.main.Main.table_stats_by_dpid_table_id")
436
    async def test_table_stats_by_dpid_table_id_not_found(self,
@@ 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."""