Passed
Push — master ( 7f62ad...2ec8a9 )
by Vinicius
02:07 queued 13s
created

conftest.intra_evc_epl_flows_data()   A

Complexity

Conditions 1

Size

Total Lines 62
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.125

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 0
dl 0
loc 62
ccs 2
cts 4
cp 0.5
crap 1.125
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
    "cbee9338673946": {
56
        "active": true,
57
        "archived": false,
58
        "backup_path": [],
59
        "bandwidth": 0,
60
        "circuit_scheduler": [],
61
        "current_path": [
62
            {
63
                "id": "78282c4",
64
                "endpoint_a": {
65
                    "id": "00:00:00:00:00:00:00:01:3",
66
                    "name": "s1-eth3",
67
                    "port_number": 3,
68
                    "mac": "16:bf:c9:82:e2:45",
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": "78282c4"
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": "2e:cf:50:f4:78:27",
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": "78282c4"
99
                },
100
                "metadata": {
101
                    "s_vlan": {
102
                        "tag_type": 1,
103
                        "value": 2
104
                    }
105
                },
106
                "active": true,
107
                "enabled": true,
108
                "status": "UP",
109
                "status_reason": []
110
            },
111
            {
112
                "id": "4d42dc0",
113
                "endpoint_a": {
114
                    "id": "00:00:00:00:00:00:00:02:3",
115
                    "name": "s2-eth3",
116
                    "port_number": 3,
117
                    "mac": "7a:aa:59:ad:40:8d",
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": "4d42dc0"
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": "72:4b:26:d0:d5:99",
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": "4d42dc0"
148
                },
149
                "metadata": {
150
                    "s_vlan": {
151
                        "tag_type": 1,
152
                        "value": 2
153
                    }
154
                },
155
                "active": true,
156
                "enabled": true,
157
                "status": "UP",
158
                "status_reason": []
159
            }
160
        ],
161
        "dynamic_backup_path": false,
162
        "enabled": true,
163
        "failover_path": [],
164
        "id": "cbee9338673946",
165
        "metadata": {},
166
        "name": "epl_static",
167
        "primary_path": [
168
            {
169
                "id": "78282c4",
170
                "endpoint_a": {
171
                    "id": "00:00:00:00:00:00:00:01:3",
172
                    "name": "s1-eth3",
173
                    "port_number": 3,
174
                    "mac": "16:bf:c9:82:e2:45",
175
                    "switch": "00:00:00:00:00:00:00:01",
176
                    "type": "interface",
177
                    "nni": true,
178
                    "uni": false,
179
                    "speed": 1250000000.0,
180
                    "metadata": {},
181
                    "lldp": true,
182
                    "active": true,
183
                    "enabled": true,
184
                    "status": "UP",
185
                    "status_reason": [],
186
                    "link": "78282c4"
187
                },
188
                "endpoint_b": {
189
                    "id": "00:00:00:00:00:00:00:02:2",
190
                    "name": "s2-eth2",
191
                    "port_number": 2,
192
                    "mac": "2e:cf:50:f4:78:27",
193
                    "switch": "00:00:00:00:00:00:00:02",
194
                    "type": "interface",
195
                    "nni": true,
196
                    "uni": false,
197
                    "speed": 1250000000.0,
198
                    "metadata": {},
199
                    "lldp": true,
200
                    "active": true,
201
                    "enabled": true,
202
                    "status": "UP",
203
                    "status_reason": [],
204
                    "link": "78282c4"
205
                },
206
                "metadata": {
207
                    "s_vlan": {
208
                        "tag_type": 1,
209
                        "value": 2
210
                    }
211
                },
212
                "active": true,
213
                "enabled": true,
214
                "status": "UP",
215
                "status_reason": []
216
            },
217
            {
218
                "id": "4d42dc0",
219
                "endpoint_a": {
220
                    "id": "00:00:00:00:00:00:00:02:3",
221
                    "name": "s2-eth3",
222
                    "port_number": 3,
223
                    "mac": "7a:aa:59:ad:40:8d",
224
                    "switch": "00:00:00:00:00:00:00:02",
225
                    "type": "interface",
226
                    "nni": true,
227
                    "uni": false,
228
                    "speed": 1250000000.0,
229
                    "metadata": {},
230
                    "lldp": true,
231
                    "active": true,
232
                    "enabled": true,
233
                    "status": "UP",
234
                    "status_reason": [],
235
                    "link": "4d42dc0"
236
                },
237
                "endpoint_b": {
238
                    "id": "00:00:00:00:00:00:00:03:2",
239
                    "name": "s3-eth2",
240
                    "port_number": 2,
241
                    "mac": "72:4b:26:d0:d5:99",
242
                    "switch": "00:00:00:00:00:00:00:03",
243
                    "type": "interface",
244
                    "nni": true,
245
                    "uni": false,
246
                    "speed": 1250000000.0,
247
                    "metadata": {},
248
                    "lldp": true,
249
                    "active": true,
250
                    "enabled": true,
251
                    "status": "UP",
252
                    "status_reason": [],
253
                    "link": "4d42dc0"
254
                },
255
                "metadata": {
256
                    "s_vlan": {
257
                        "tag_type": 1,
258
                        "value": 2
259
                    }
260
                },
261
                "active": true,
262
                "enabled": true,
263
                "status": "UP",
264
                "status_reason": []
265
            }
266
        ],
267
        "service_level": 0,
268
        "uni_a": {
269
            "interface_id": "00:00:00:00:00:00:00:01:1"
270
        },
271
        "uni_z": {
272
            "interface_id": "00:00:00:00:00:00:00:03:1"
273
        },
274
        "sb_priority": null,
275
        "execution_rounds": 0,
276
        "owner": null,
277
        "queue_id": null,
278
        "primary_constraints": {},
279
        "secondary_constraints": {},
280
        "primary_links": [],
281
        "backup_links": [],
282
        "start_date": "2023-07-28T23:30:59",
283
        "creation_time": "2023-07-28T23:30:59",
284
        "request_time": "2023-07-28T23:30:59",
285
        "end_date": null,
286
        "flow_removed_at": null,
287
        "updated_at": "2023-07-28T23:30:59"
288
    }
289
}
290
"""
291 1
    return json.loads(data)
292
293
294 1
@pytest.fixture
295 1
def intra_evc_evpl_flows_data() -> dict:
296
    """Intra EVC EVPL flows data."""
297 1
    data = """
298
{
299
    "00:00:00:00:00:00:00:01": [
300
        {
301
            "flow": {
302
                "owner": "mef_eline",
303
                "cookie": 12265385089372284745,
304
                "match": {
305
                    "in_port": 1,
306
                    "dl_vlan": 200
307
                },
308
                "actions": [
309
                    {
310
                        "action_type": "set_vlan",
311
                        "vlan_id": 200
312
                    },
313
                    {
314
                        "action_type": "output",
315
                        "port": 2
316
                    }
317
                ],
318
                "table_id": 0,
319
                "table_group": "evpl",
320
                "priority": 20000,
321
                "idle_timeout": 0,
322
                "hard_timeout": 0
323
            },
324
            "flow_id": "898c09a40b5e3e892b815c2a6bad532d",
325
            "id": "f7562d356cd900cb227b018ef27c5189",
326
            "inserted_at": "2023-07-28T18:21:15.875000",
327
            "state": "installed",
328
            "switch": "00:00:00:00:00:00:00:01",
329
            "updated_at": "2023-07-28T23:01:12.663000"
330
        },
331
        {
332
            "flow": {
333
                "owner": "mef_eline",
334
                "cookie": 12265385089372284745,
335
                "match": {
336
                    "in_port": 2,
337
                    "dl_vlan": 200
338
                },
339
                "actions": [
340
                    {
341
                        "action_type": "set_vlan",
342
                        "vlan_id": 200
343
                    },
344
                    {
345
                        "action_type": "output",
346
                        "port": 1
347
                    }
348
                ],
349
                "table_id": 0,
350
                "table_group": "evpl",
351
                "priority": 20000,
352
                "idle_timeout": 0,
353
                "hard_timeout": 0
354
            },
355
            "flow_id": "9ea45a8287939d63f1d3409e89131a04",
356
            "id": "10cf10fbc4d3c7e4c4b931ff217c81e8",
357
            "inserted_at": "2023-07-28T18:21:15.875000",
358
            "state": "installed",
359
            "switch": "00:00:00:00:00:00:00:01",
360
            "updated_at": "2023-07-28T23:01:12.664000"
361
        }
362
    ]
363
}
364
"""
365 1
    return json.loads(data)
366
367
368 1
@pytest.fixture
369 1
def intra_evc_epl_flows_data() -> dict:
370
    """Intra EVC EPL flows data."""
371
    data = """
372
{
373
    "00:00:00:00:00:00:00:01": [
374
        {
375
            "flow": {
376
                "owner": "mef_eline",
377
                "cookie": 12265385089372284745,
378
                "match": {
379
                    "in_port": 1
380
                },
381
                "actions": [
382
                    {
383
                        "action_type": "output",
384
                        "port": 2
385
                    }
386
                ],
387
                "table_id": 0,
388
                "table_group": "epl",
389
                "priority": 10000,
390
                "idle_timeout": 0,
391
                "hard_timeout": 0
392
            },
393
            "flow_id": "898c09a40b5e3e892b815c2a6bad532d",
394
            "id": "f7562d356cd900cb227b018ef27c5189",
395
            "inserted_at": "2023-07-28T18:21:15.875000",
396
            "state": "installed",
397
            "switch": "00:00:00:00:00:00:00:01",
398
            "updated_at": "2023-07-28T23:01:12.663000"
399
        },
400
        {
401
            "flow": {
402
                "owner": "mef_eline",
403
                "cookie": 12265385089372284745,
404
                "match": {
405
                    "in_port": 2,
406
                },
407
                "actions": [
408
                    {
409
                        "action_type": "output",
410
                        "port": 1
411
                    }
412
                ],
413
                "table_id": 0,
414
                "table_group": "epl",
415
                "priority": 10000,
416
                "idle_timeout": 0,
417
                "hard_timeout": 0
418
            },
419
            "flow_id": "9ea45a8287939d63f1d3409e89131a04",
420
            "id": "10cf10fbc4d3c7e4c4b931ff217c81e8",
421
            "inserted_at": "2023-07-28T18:21:15.875000",
422
            "state": "installed",
423
            "switch": "00:00:00:00:00:00:00:01",
424
            "updated_at": "2023-07-28T23:01:12.664000"
425
        }
426
    ]
427
}
428
"""
429
    return json.loads(data)
430