Code Duplication    Length = 12-13 lines in 4 locations

tests/unit/test_main.py 4 locations

@@ 292-304 (lines=13) @@
289
        expected_result = {"1": circuits["1"]}
290
        self.assertEqual(json.loads(response.data), expected_result)
291
292
    @patch("napps.kytos.mef_eline.storehouse.StoreHouse.get_data")
293
    def test_list_with_archived_circuits_stored_2(self, storehouse_data_mock):
294
        """Test if list circuits return all circuits."""
295
        circuits = {
296
            "1": {"name": "circuit_1"},
297
            "2": {"name": "circuit_2", "archived": True},
298
        }
299
        storehouse_data_mock.return_value = circuits
300
301
        api = self.get_app_test_client(self.napp)
302
        url = f"{self.server_name_url}/v2/evc/?archived=True"
303
304
        response = api.get(url)
305
        expected_result = circuits
306
        self.assertEqual(json.loads(response.data), expected_result)
307
@@ 276-288 (lines=13) @@
273
        expected_result = circuits
274
        self.assertEqual(json.loads(response.data), expected_result)
275
276
    @patch("napps.kytos.mef_eline.storehouse.StoreHouse.get_data")
277
    def test_list_with_archived_circuits_stored_1(self, storehouse_data_mock):
278
        """Test if list circuits return only circuits not archived."""
279
        circuits = {
280
            "1": {"name": "circuit_1"},
281
            "2": {"name": "circuit_2", "archived": True},
282
        }
283
        storehouse_data_mock.return_value = circuits
284
285
        api = self.get_app_test_client(self.napp)
286
        url = f"{self.server_name_url}/v2/evc/"
287
288
        response = api.get(url)
289
        expected_result = {"1": circuits["1"]}
290
        self.assertEqual(json.loads(response.data), expected_result)
291
@@ 320-332 (lines=13) @@
317
        expected_result = circuits["1"]
318
        self.assertEqual(json.loads(response.data), expected_result)
319
320
    @patch("napps.kytos.mef_eline.storehouse.StoreHouse.get_data")
321
    def test_circuit_with_invalid_id(self, storehouse_data_mock):
322
        """Test if get_circuit return invalid circuit_id."""
323
        circuits = {"1": {"name": "circuit_1"}, "2": {"name": "circuit_2"}}
324
        storehouse_data_mock.return_value = circuits
325
326
        api = self.get_app_test_client(self.napp)
327
        url = f"{self.server_name_url}/v2/evc/3"
328
        response = api.get(url)
329
        expected_result = "circuit_id 3 not found"
330
        self.assertEqual(
331
            json.loads(response.data)["description"], expected_result
332
        )
333
334
    @patch("napps.kytos.mef_eline.models.evc.EVC.deploy")
335
    @patch("napps.kytos.mef_eline.storehouse.StoreHouse.get_data")
@@ 308-319 (lines=12) @@
305
        expected_result = circuits
306
        self.assertEqual(json.loads(response.data), expected_result)
307
308
    @patch("napps.kytos.mef_eline.storehouse.StoreHouse.get_data")
309
    def test_circuit_with_valid_id(self, storehouse_data_mock):
310
        """Test if get_circuit return the circuit attributes."""
311
        circuits = {"1": {"name": "circuit_1"}, "2": {"name": "circuit_2"}}
312
        storehouse_data_mock.return_value = circuits
313
314
        api = self.get_app_test_client(self.napp)
315
        url = f"{self.server_name_url}/v2/evc/1"
316
        response = api.get(url)
317
        expected_result = circuits["1"]
318
        self.assertEqual(json.loads(response.data), expected_result)
319
320
    @patch("napps.kytos.mef_eline.storehouse.StoreHouse.get_data")
321
    def test_circuit_with_invalid_id(self, storehouse_data_mock):
322
        """Test if get_circuit return invalid circuit_id."""