Code Duplication    Length = 47-49 lines in 2 locations

tests/unit/test_main.py 2 locations

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