Code Duplication    Length = 47-49 lines in 2 locations

tests/unit/test_main.py 2 locations

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