Code Duplication    Length = 47-49 lines in 2 locations

tests/unit/test_main.py 2 locations

@@ 242-290 (lines=49) @@
239
        self.assertIsNotNone(evc_response.name)
240
        self.assertIsNotNone(evc_response.queue_id)
241
242
    @patch("napps.kytos.mef_eline.main.Main._uni_from_dict")
243
    @patch("napps.kytos.mef_eline.models.evc.EVCBase._validate")
244
    @patch("kytos.core.Controller.get_interface_by_id")
245
    def test_evc_from_dict_paths(
246
        self, _get_interface_by_id_mock, _validate_mock, uni_from_dict_mock
247
    ):
248
        """
249
        Test the helper method that create an EVN from dict.
250
251
        Verify object creation with circuit data and schedule data.
252
        """
253
254
        _get_interface_by_id_mock.return_value = get_uni_mocked().interface
255
        _validate_mock.return_value = True
256
        uni_from_dict_mock.side_effect = ["uni_a", "uni_z"]
257
        payload = {
258
            "name": "my evc1",
259
            "uni_a": {
260
                "interface_id": "00:00:00:00:00:00:00:01:1",
261
                "tag": {"tag_type": 1, "value": 80},
262
            },
263
            "uni_z": {
264
                "interface_id": "00:00:00:00:00:00:00:02:2",
265
                "tag": {"tag_type": 1, "value": 1},
266
            },
267
            "current_path": [],
268
            "primary_path": [
269
                {
270
                    "endpoint_a": {
271
                        "interface_id": "00:00:00:00:00:00:00:01:1"
272
                    },
273
                    "endpoint_b": {
274
                        "interface_id": "00:00:00:00:00:00:00:02:2"
275
                    },
276
                }
277
            ],
278
            "backup_path": [],
279
        }
280
281
        # pylint: disable=protected-access
282
        evc_response = self.napp._evc_from_dict(payload)
283
        self.assertIsNotNone(evc_response)
284
        self.assertIsNotNone(evc_response.uni_a)
285
        self.assertIsNotNone(evc_response.uni_z)
286
        self.assertIsNotNone(evc_response.circuit_scheduler)
287
        self.assertIsNotNone(evc_response.name)
288
        self.assertEqual(len(evc_response.current_path), 0)
289
        self.assertEqual(len(evc_response.backup_path), 0)
290
        self.assertEqual(len(evc_response.primary_path), 1)
291
292
    @patch("napps.kytos.mef_eline.main.Main._uni_from_dict")
293
    @patch("napps.kytos.mef_eline.models.evc.EVCBase._validate")
@@ 292-338 (lines=47) @@
289
        self.assertEqual(len(evc_response.backup_path), 0)
290
        self.assertEqual(len(evc_response.primary_path), 1)
291
292
    @patch("napps.kytos.mef_eline.main.Main._uni_from_dict")
293
    @patch("napps.kytos.mef_eline.models.evc.EVCBase._validate")
294
    @patch("kytos.core.Controller.get_interface_by_id")
295
    def test_evc_from_dict_links(
296
        self, _get_interface_by_id_mock, _validate_mock, uni_from_dict_mock
297
    ):
298
        """
299
        Test the helper method that create an EVN from dict.
300
301
        Verify object creation with circuit data and schedule data.
302
        """
303
        _get_interface_by_id_mock.return_value = get_uni_mocked().interface
304
        _validate_mock.return_value = True
305
        uni_from_dict_mock.side_effect = ["uni_a", "uni_z"]
306
        payload = {
307
            "name": "my evc1",
308
            "uni_a": {
309
                "interface_id": "00:00:00:00:00:00:00:01:1",
310
                "tag": {"tag_type": 1, "value": 80},
311
            },
312
            "uni_z": {
313
                "interface_id": "00:00:00:00:00:00:00:02:2",
314
                "tag": {"tag_type": 1, "value": 1},
315
            },
316
            "primary_links": [
317
                {
318
                    "endpoint_a": {
319
                        "interface_id": "00:00:00:00:00:00:00:01:1"
320
                    },
321
                    "endpoint_b": {
322
                        "interface_id": "00:00:00:00:00:00:00:02:2"
323
                    },
324
                }
325
            ],
326
            "backup_links": [],
327
        }
328
329
        # pylint: disable=protected-access
330
        evc_response = self.napp._evc_from_dict(payload)
331
        self.assertIsNotNone(evc_response)
332
        self.assertIsNotNone(evc_response.uni_a)
333
        self.assertIsNotNone(evc_response.uni_z)
334
        self.assertIsNotNone(evc_response.circuit_scheduler)
335
        self.assertIsNotNone(evc_response.name)
336
        self.assertEqual(len(evc_response.current_links_cache), 0)
337
        self.assertEqual(len(evc_response.backup_links), 0)
338
        self.assertEqual(len(evc_response.primary_links), 1)
339
340
    def test_list_without_circuits(self):
341
        """Test if list circuits return 'no circuit stored.'."""