conftest   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 582
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 33
dl 0
loc 582
ccs 30
cts 30
cp 1
rs 10
c 0
b 0
f 0
wmc 9

5 Functions

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