Passed
Pull Request — master (#53)
by Vinicius
02:59
created

conftest.intra_evc_evpl_flows_data()   A

Complexity

Conditions 1

Size

Total Lines 72
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 0
dl 0
loc 72
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
"""Conftest."""
2 1
import json
3 1
import pytest
4
5
6 1
@pytest.fixture
7 1
def evcs_data() -> dict:
8
    """evcs_data."""
9 1
    data = """
10
{
11
    "3766c105686749": {
12
        "active": true,
13
        "archived": false,
14
        "backup_path": [],
15
        "bandwidth": 0,
16
        "circuit_scheduler": [],
17
        "current_path": [],
18
        "dynamic_backup_path": true,
19
        "enabled": true,
20
        "failover_path": [],
21
        "id": "3766c105686749",
22
        "metadata": {},
23
        "name": "evpl",
24
        "primary_path": [],
25
        "service_level": 6,
26
        "uni_a": {
27
            "tag": {
28
                "tag_type": 1,
29
                "value": 200
30
            },
31
            "interface_id": "00:00:00:00:00:00:00:01:1"
32
        },
33
        "uni_z": {
34
            "tag": {
35
                "tag_type": 1,
36
                "value": 200
37
            },
38
            "interface_id": "00:00:00:00:00:00:00:01:2"
39
        },
40
        "sb_priority": null,
41
        "execution_rounds": 0,
42
        "owner": null,
43
        "queue_id": null,
44
        "primary_constraints": {},
45
        "secondary_constraints": {},
46
        "primary_links": [],
47
        "backup_links": [],
48
        "start_date": "2023-07-28T18:21:15",
49
        "creation_time": "2023-07-28T18:21:15",
50
        "request_time": "2023-07-28T18:21:15",
51
        "end_date": null,
52
        "flow_removed_at": null,
53
        "updated_at": "2023-07-28T23:02:04"
54
    },
55
    "16a76ae61b2f46": {
56
        "active": true,
57
        "archived": false,
58
        "backup_path": [],
59
        "bandwidth": 0,
60
        "circuit_scheduler": [],
61
        "current_path": [
62
            {
63
                "id": "78282c4d5",
64
                "endpoint_a": {
65
                    "id": "00:00:00:00:00:00:00:01:3",
66
                    "name": "s1-eth3",
67
                    "port_number": 3,
68
                    "mac": "7e:b7:b4:cd:dd:ad",
69
                    "switch": "00:00:00:00:00:00:00:01",
70
                    "type": "interface",
71
                    "nni": true,
72
                    "uni": false,
73
                    "speed": 1250000000.0,
74
                    "metadata": {},
75
                    "lldp": true,
76
                    "active": true,
77
                    "enabled": true,
78
                    "status": "UP",
79
                    "status_reason": [],
80
                    "link": "78282c4d5"
81
                },
82
                "endpoint_b": {
83
                    "id": "00:00:00:00:00:00:00:02:2",
84
                    "name": "s2-eth2",
85
                    "port_number": 2,
86
                    "mac": "a6:57:de:b1:a2:f6",
87
                    "switch": "00:00:00:00:00:00:00:02",
88
                    "type": "interface",
89
                    "nni": true,
90
                    "uni": false,
91
                    "speed": 1250000000.0,
92
                    "metadata": {},
93
                    "lldp": true,
94
                    "active": true,
95
                    "enabled": true,
96
                    "status": "UP",
97
                    "status_reason": [],
98
                    "link": "78282c4d5"
99
                },
100
                "metadata": {
101
                    "s_vlan": {
102
                        "tag_type": 1,
103
                        "value": 1
104
                    }
105
                },
106
                "active": true,
107
                "enabled": true,
108
                "status": "UP",
109
                "status_reason": []
110
            },
111
            {
112
                "id": "4d42dc085",
113
                "endpoint_a": {
114
                    "id": "00:00:00:00:00:00:00:02:3",
115
                    "name": "s2-eth3",
116
                    "port_number": 3,
117
                    "mac": "4e:2e:61:6c:f4:c0",
118
                    "switch": "00:00:00:00:00:00:00:02",
119
                    "type": "interface",
120
                    "nni": true,
121
                    "uni": false,
122
                    "speed": 1250000000.0,
123
                    "metadata": {},
124
                    "lldp": true,
125
                    "active": true,
126
                    "enabled": true,
127
                    "status": "UP",
128
                    "status_reason": [],
129
                    "link": "4d42dc085"
130
                },
131
                "endpoint_b": {
132
                    "id": "00:00:00:00:00:00:00:03:2",
133
                    "name": "s3-eth2",
134
                    "port_number": 2,
135
                    "mac": "9e:84:49:fc:13:14",
136
                    "switch": "00:00:00:00:00:00:00:03",
137
                    "type": "interface",
138
                    "nni": true,
139
                    "uni": false,
140
                    "speed": 1250000000.0,
141
                    "metadata": {},
142
                    "lldp": true,
143
                    "active": true,
144
                    "enabled": true,
145
                    "status": "UP",
146
                    "status_reason": [],
147
                    "link": "4d42dc085"
148
                },
149
                "metadata": {
150
                    "s_vlan": {
151
                        "tag_type": 1,
152
                        "value": 1
153
                    }
154
                },
155
                "active": true,
156
                "enabled": true,
157
                "status": "UP",
158
                "status_reason": []
159
            }
160
        ],
161
        "dynamic_backup_path": true,
162
        "enabled": true,
163
        "failover_path": [],
164
        "id": "16a76ae61b2f46",
165
        "metadata": {},
166
        "name": "evpl",
167
        "primary_path": [],
168
        "service_level": 6,
169
        "uni_a": {
170
            "tag": {
171
                "tag_type": 1,
172
                "value": 101
173
            },
174
            "interface_id": "00:00:00:00:00:00:00:01:1"
175
        },
176
        "uni_z": {
177
            "tag": {
178
                "tag_type": 1,
179
                "value": 102
180
            },
181
            "interface_id": "00:00:00:00:00:00:00:03:1"
182
        },
183
        "sb_priority": null,
184
        "execution_rounds": 0,
185
        "owner": null,
186
        "queue_id": -1,
187
        "primary_constraints": {
188
            "mandatory_metrics": {
189
                "ownership": "blue"
190
            }
191
        },
192
        "secondary_constraints": {
193
            "mandatory_metrics": {
194
                "ownership": "blue"
195
            }
196
        },
197
        "primary_links": [],
198
        "backup_links": [],
199
        "start_date": "2023-09-15T13:11:53",
200
        "creation_time": "2023-09-15T13:11:53",
201
        "request_time": "2023-09-15T13:11:53",
202
        "end_date": null,
203
        "flow_removed_at": null,
204
        "updated_at": "2023-09-15T13:11:53"
205
    }
206
}
207
"""
208 1
    return json.loads(data)
209
210
211 1
@pytest.fixture
212 1
def intra_evc_evpl_flows_data() -> dict:
213
    """Intra EVC EVPL flows data."""
214 1
    data = """
215
{
216
    "00:00:00:00:00:00:00:01": [
217
        {
218
            "flow": {
219
                "owner": "mef_eline",
220
                "cookie": 12265385089372284745,
221
                "match": {
222
                    "in_port": 1,
223
                    "dl_vlan": 200
224
                },
225
                "actions": [
226
                    {
227
                        "action_type": "set_vlan",
228
                        "vlan_id": 200
229
                    },
230
                    {
231
                        "action_type": "output",
232
                        "port": 2
233
                    }
234
                ],
235
                "table_id": 0,
236
                "table_group": "evpl",
237
                "priority": 20000,
238
                "idle_timeout": 0,
239
                "hard_timeout": 0
240
            },
241
            "flow_id": "898c09a40b5e3e892b815c2a6bad532d",
242
            "id": "f7562d356cd900cb227b018ef27c5189",
243
            "inserted_at": "2023-07-28T18:21:15.875000",
244
            "state": "installed",
245
            "switch": "00:00:00:00:00:00:00:01",
246
            "updated_at": "2023-07-28T23:01:12.663000"
247
        },
248
        {
249
            "flow": {
250
                "owner": "mef_eline",
251
                "cookie": 12265385089372284745,
252
                "match": {
253
                    "in_port": 2,
254
                    "dl_vlan": 200
255
                },
256
                "actions": [
257
                    {
258
                        "action_type": "set_vlan",
259
                        "vlan_id": 200
260
                    },
261
                    {
262
                        "action_type": "output",
263
                        "port": 1
264
                    }
265
                ],
266
                "table_id": 0,
267
                "table_group": "evpl",
268
                "priority": 20000,
269
                "idle_timeout": 0,
270
                "hard_timeout": 0
271
            },
272
            "flow_id": "9ea45a8287939d63f1d3409e89131a04",
273
            "id": "10cf10fbc4d3c7e4c4b931ff217c81e8",
274
            "inserted_at": "2023-07-28T18:21:15.875000",
275
            "state": "installed",
276
            "switch": "00:00:00:00:00:00:00:01",
277
            "updated_at": "2023-07-28T23:01:12.664000"
278
        }
279
    ]
280
}
281
"""
282 1
    return json.loads(data)
283
284
285 1
@pytest.fixture
286 1
def intra_evc_epl_flows_data() -> dict:
287
    """Intra EVC EPL flows data."""
288 1
    data = """
289
{
290
    "00:00:00:00:00:00:00:01": [
291
        {
292
            "flow": {
293
                "owner": "mef_eline",
294
                "cookie": 12265385089372284745,
295
                "match": {
296
                    "in_port": 1
297
                },
298
                "actions": [
299
                    {
300
                        "action_type": "output",
301
                        "port": 2
302
                    }
303
                ],
304
                "table_id": 0,
305
                "table_group": "epl",
306
                "priority": 10000,
307
                "idle_timeout": 0,
308
                "hard_timeout": 0
309
            },
310
            "flow_id": "898c09a40b5e3e892b815c2a6bad532d",
311
            "id": "f7562d356cd900cb227b018ef27c5189",
312
            "inserted_at": "2023-07-28T18:21:15.875000",
313
            "state": "installed",
314
            "switch": "00:00:00:00:00:00:00:01",
315
            "updated_at": "2023-07-28T23:01:12.663000"
316
        },
317
        {
318
            "flow": {
319
                "owner": "mef_eline",
320
                "cookie": 12265385089372284745,
321
                "match": {
322
                    "in_port": 2
323
                },
324
                "actions": [
325
                    {
326
                        "action_type": "output",
327
                        "port": 1
328
                    }
329
                ],
330
                "table_id": 0,
331
                "table_group": "epl",
332
                "priority": 10000,
333
                "idle_timeout": 0,
334
                "hard_timeout": 0
335
            },
336
            "flow_id": "9ea45a8287939d63f1d3409e89131a04",
337
            "id": "10cf10fbc4d3c7e4c4b931ff217c81e8",
338
            "inserted_at": "2023-07-28T18:21:15.875000",
339
            "state": "installed",
340
            "switch": "00:00:00:00:00:00:00:01",
341
            "updated_at": "2023-07-28T23:01:12.664000"
342
        }
343
    ]
344
}
345
"""
346 1
    return json.loads(data)
347
348
349 1
@pytest.fixture
350 1
def inter_evc_evpl_flows_data() -> None:
351
    """inter evc evpl flows data."""
352 1
    data = """
353
{
354
    "00:00:00:00:00:00:00:02": [
355
        {
356
            "flow": {
357
                "owner": "mef_eline",
358
                "cookie": 12256167513504296774,
359
                "match": {
360
                    "in_port": 2,
361
                    "dl_vlan": 1
362
                },
363
                "actions": [
364
                    {
365
                        "action_type": "set_vlan",
366
                        "vlan_id": 1
367
                    },
368
                    {
369
                        "action_type": "output",
370
                        "port": 3
371
                    }
372
                ],
373
                "table_id": 0,
374
                "table_group": "evpl",
375
                "priority": 20000,
376
                "idle_timeout": 0,
377
                "hard_timeout": 0
378
            },
379
            "flow_id": "4718c55780c7ff62be3fcb09f4e3d06f",
380
            "id": "c96c36720cd2c9d761345588bf68c33a",
381
            "inserted_at": "2023-09-15T13:11:53.147000",
382
            "state": "installed",
383
            "switch": "00:00:00:00:00:00:00:02",
384
            "updated_at": "2023-09-15T13:11:53.158000"
385
        },
386
        {
387
            "flow": {
388
                "owner": "mef_eline",
389
                "cookie": 12256167513504296774,
390
                "match": {
391
                    "in_port": 3,
392
                    "dl_vlan": 1
393
                },
394
                "actions": [
395
                    {
396
                        "action_type": "set_vlan",
397
                        "vlan_id": 1
398
                    },
399
                    {
400
                        "action_type": "output",
401
                        "port": 2
402
                    }
403
                ],
404
                "table_id": 0,
405
                "table_group": "evpl",
406
                "priority": 20000,
407
                "idle_timeout": 0,
408
                "hard_timeout": 0
409
            },
410
            "flow_id": "f4f4950beaf5bc8cb4b86c6799e2759e",
411
            "id": "aefa4b6945337beb3125b96c60ecce28",
412
            "inserted_at": "2023-09-15T13:11:53.147000",
413
            "state": "installed",
414
            "switch": "00:00:00:00:00:00:00:02",
415
            "updated_at": "2023-09-15T13:11:53.158000"
416
        }
417
    ],
418
    "00:00:00:00:00:00:00:01": [
419
        {
420
            "flow": {
421
                "owner": "mef_eline",
422
                "cookie": 12256167513504296774,
423
                "match": {
424
                    "in_port": 1,
425
                    "dl_vlan": 101
426
                },
427
                "actions": [
428
                    {
429
                        "action_type": "set_vlan",
430
                        "vlan_id": 102
431
                    },
432
                    {
433
                        "action_type": "push_vlan",
434
                        "tag_type": "s"
435
                    },
436
                    {
437
                        "action_type": "set_vlan",
438
                        "vlan_id": 1
439
                    },
440
                    {
441
                        "action_type": "output",
442
                        "port": 3
443
                    }
444
                ],
445
                "table_id": 0,
446
                "table_group": "evpl",
447
                "priority": 20000,
448
                "idle_timeout": 0,
449
                "hard_timeout": 0
450
            },
451
            "flow_id": "97e07c78a6f19bb4b4c7a13d2fc2a1bc",
452
            "id": "114d32fe5e21cbad93fe9881f579e9de",
453
            "inserted_at": "2023-09-15T13:11:53.162000",
454
            "state": "installed",
455
            "switch": "00:00:00:00:00:00:00:01",
456
            "updated_at": "2023-09-15T13:11:53.184000"
457
        },
458
        {
459
            "flow": {
460
                "owner": "mef_eline",
461
                "cookie": 12256167513504296774,
462
                "match": {
463
                    "in_port": 3,
464
                    "dl_vlan": 1
465
                },
466
                "actions": [
467
                    {
468
                        "action_type": "pop_vlan"
469
                    },
470
                    {
471
                        "action_type": "output",
472
                        "port": 1
473
                    }
474
                ],
475
                "table_id": 0,
476
                "table_group": "evpl",
477
                "priority": 20000,
478
                "idle_timeout": 0,
479
                "hard_timeout": 0
480
            },
481
            "flow_id": "40cdc7cbea439f4f714d2f2bc1dd0380",
482
            "id": "9f15a56df3e30ef08745fdf16c5f389b",
483
            "inserted_at": "2023-09-15T13:11:53.162000",
484
            "state": "installed",
485
            "switch": "00:00:00:00:00:00:00:01",
486
            "updated_at": "2023-09-15T13:11:53.184000"
487
        }
488
    ],
489
    "00:00:00:00:00:00:00:03": [
490
        {
491
            "flow": {
492
                "owner": "mef_eline",
493
                "cookie": 12256167513504296774,
494
                "match": {
495
                    "in_port": 1,
496
                    "dl_vlan": 102
497
                },
498
                "actions": [
499
                    {
500
                        "action_type": "set_vlan",
501
                        "vlan_id": 101
502
                    },
503
                    {
504
                        "action_type": "push_vlan",
505
                        "tag_type": "s"
506
                    },
507
                    {
508
                        "action_type": "set_vlan",
509
                        "vlan_id": 1
510
                    },
511
                    {
512
                        "action_type": "output",
513
                        "port": 2
514
                    }
515
                ],
516
                "table_id": 0,
517
                "table_group": "evpl",
518
                "priority": 20000,
519
                "idle_timeout": 0,
520
                "hard_timeout": 0
521
            },
522
            "flow_id": "c3358aa562a5293443248ba6d551c623",
523
            "id": "d830b9abbc4db82cd25169c0a91544b5",
524
            "inserted_at": "2023-09-15T13:11:53.188000",
525
            "state": "installed",
526
            "switch": "00:00:00:00:00:00:00:03",
527
            "updated_at": "2023-09-15T13:11:53.201000"
528
        },
529
        {
530
            "flow": {
531
                "owner": "mef_eline",
532
                "cookie": 12256167513504296774,
533
                "match": {
534
                    "in_port": 2,
535
                    "dl_vlan": 1
536
                },
537
                "actions": [
538
                    {
539
                        "action_type": "pop_vlan"
540
                    },
541
                    {
542
                        "action_type": "output",
543
                        "port": 1
544
                    }
545
                ],
546
                "table_id": 0,
547
                "table_group": "evpl",
548
                "priority": 20000,
549
                "idle_timeout": 0,
550
                "hard_timeout": 0
551
            },
552
            "flow_id": "9b96726b751a36c83eaaaee243181160",
553
            "id": "106216e182ee653cf1901c3170efee23",
554
            "inserted_at": "2023-09-15T13:11:53.188000",
555
            "state": "installed",
556
            "switch": "00:00:00:00:00:00:00:03",
557
            "updated_at": "2023-09-15T13:11:53.201000"
558
        }
559
    ]
560
}
561
"""
562
    return json.loads(data)
563