@@ -143,85 +143,57 @@ def test_init(mock_netbox_module, find_ids_return):
143
143
assert mock_netbox_module .data == find_ids_return
144
144
145
145
146
- def test_normalize_data_returns_correct_data (mock_netbox_module ):
147
- data = {
148
- "circuit" : "Test-Circuit-1000" ,
149
- "circuit_termination" : "Test Circuit" ,
150
- "circuit_type" : "Test Circuit Type" ,
151
- "cluster" : "Test Cluster" ,
152
- "cluster_group" : "Test Cluster_group" ,
153
- "cluster_type" : "Test Cluster Type" ,
154
- "device" : "Test Device" ,
155
- "device_role" : "Core Switch" ,
156
- "device_type" : "Cisco Switch" ,
157
- "group" : "Test Group1" ,
158
- "installed_device" : "Test Device" ,
159
- "manufacturer" : "Cisco" ,
160
- "nat_inside" : "192.168.1.1/24" ,
161
- "nat_outside" : "192.168.10.1/24" ,
162
- "platform" : "Cisco IOS" ,
163
- "prefix_role" : "TEst Role-1" ,
164
- "primary_ip" : "192.168.1.1/24" ,
165
- "primary_ip4" : "192.168.1.1/24" ,
166
- "primary_ip6" : "2001::1/128" ,
167
- "provider" : "Test Provider" ,
168
- "rack" : "Test Rack" ,
169
- "rack_group" : "RacK_group" ,
170
- "rack_role" : "Test Rack Role" ,
171
- "region" : "Test Region_1" ,
172
- "rir" : "Test RIR_One" ,
173
- "prefix_role" : "TEst Role-1" ,
174
- "slug" : "Test to_slug" ,
175
- "site" : "Test Site" ,
176
- "tenant" : "Test Tenant" ,
177
- "tenant_group" : "Test Tenant Group" ,
178
- "time_zone" : "America/Los Angeles" ,
179
- "virtual_machine" : "Test VM 100" ,
180
- "vlan" : "Test VLAN" ,
181
- "vlan_group" : "Test VLAN Group" ,
182
- "vlan_role" : "Access Role" ,
183
- "vrf" : "Test VRF" ,
184
- }
185
- norm_data_expected = {
186
- "circuit" : "Test-Circuit-1000" ,
187
- "circuit_termination" : "Test Circuit" ,
188
- "circuit_type" : "test-circuit-type" ,
189
- "cluster" : "Test Cluster" ,
190
- "cluster_group" : "test-cluster_group" ,
191
- "cluster_type" : "test-cluster-type" ,
192
- "device" : "Test Device" ,
193
- "device_role" : "core-switch" ,
194
- "device_type" : "cisco-switch" ,
195
- "group" : "test-group1" ,
196
- "installed_device" : "Test Device" ,
197
- "manufacturer" : "cisco" ,
198
- "nat_inside" : "192.168.1.1/24" ,
199
- "nat_outside" : "192.168.10.1/24" ,
200
- "platform" : "cisco-ios" ,
201
- "prefix_role" : "test-role-1" ,
202
- "primary_ip" : "192.168.1.1/24" ,
203
- "primary_ip4" : "192.168.1.1/24" ,
204
- "primary_ip6" : "2001::1/128" ,
205
- "provider" : "test-provider" ,
206
- "rack" : "Test Rack" ,
207
- "rack_group" : "rack_group" ,
208
- "rack_role" : "test-rack-role" ,
209
- "region" : "test-region_1" ,
210
- "rir" : "test-rir_one" ,
211
- "slug" : "test-to_slug" ,
212
- "site" : "test-site" ,
213
- "tenant" : "Test Tenant" ,
214
- "tenant_group" : "test-tenant-group" ,
215
- "time_zone" : "America/Los_Angeles" ,
216
- "virtual_machine" : "Test VM 100" ,
217
- "vlan" : "Test VLAN" ,
218
- "vlan_group" : "test-vlan-group" ,
219
- "vlan_role" : "Access Role" ,
220
- "vrf" : "Test VRF" ,
221
- }
222
- norm_data = mock_netbox_module ._normalize_data (data )
146
+ @pytest .mark .parametrize (
147
+ "before, after" ,
148
+ [
149
+ ({"circuit" : "Test-Circuit-1000" }, {"circuit" : "Test-Circuit-1000" }),
150
+ (
151
+ {"circuit_termination" : "Test Circuit" },
152
+ {"circuit_termination" : "Test Circuit" },
153
+ ),
154
+ ({"circuit_type" : "Test Circuit Type" }, {"circuit_type" : "test-circuit-type" }),
155
+ ({"cluster" : "Test Cluster" }, {"cluster" : "Test Cluster" }),
156
+ (
157
+ {"cluster_group" : "Test Cluster_group" },
158
+ {"cluster_group" : "test-cluster_group" },
159
+ ),
160
+ ({"cluster_type" : "Test Cluster Type" }, {"cluster_type" : "test-cluster-type" }),
161
+ ({"device" : "Test Device" }, {"device" : "Test Device" }),
162
+ ({"device_role" : "Core Switch" }, {"device_role" : "core-switch" }),
163
+ ({"device_type" : "Cisco Switch" }, {"device_type" : "cisco-switch" }),
164
+ ({"group" : "Test Group1" }, {"group" : "test-group1" }),
165
+ ({"installed_device" : "Test Device" }, {"installed_device" : "Test Device" }),
166
+ ({"manufacturer" : "Cisco" }, {"manufacturer" : "cisco" }),
167
+ ({"nat_inside" : "192.168.1.1/24" }, {"nat_inside" : "192.168.1.1/24" }),
168
+ ({"nat_outside" : "192.168.10.1/24" }, {"nat_outside" : "192.168.10.1/24" }),
169
+ ({"platform" : "Cisco IOS" }, {"platform" : "cisco-ios" }),
170
+ ({"prefix_role" : "TEst Role-1" }, {"prefix_role" : "test-role-1" }),
171
+ ({"primary_ip" : "192.168.1.1/24" }, {"primary_ip" : "192.168.1.1/24" }),
172
+ ({"primary_ip4" : "192.168.1.1/24" }, {"primary_ip4" : "192.168.1.1/24" }),
173
+ ({"primary_ip6" : "2001::1/128" }, {"primary_ip6" : "2001::1/128" }),
174
+ ({"provider" : "Test Provider" }, {"provider" : "test-provider" }),
175
+ ({"rack" : "Test Rack" }, {"rack" : "Test Rack" }),
176
+ ({"rack_group" : "RacK_group" }, {"rack_group" : "rack_group" }),
177
+ ({"rack_role" : "Test Rack Role" }, {"rack_role" : "test-rack-role" }),
178
+ ({"region" : "Test Region_1" }, {"region" : "test-region_1" }),
179
+ ({"rir" : "Test RIR_One" }, {"rir" : "test-rir_one" }),
180
+ ({"prefix_role" : "TEst Role-1" }, {"prefix_role" : "test-role-1" }),
181
+ ({"slug" : "Test to_slug" }, {"slug" : "test-to_slug" }),
182
+ ({"site" : "Test Site" }, {"site" : "test-site" }),
183
+ ({"tenant" : "Test Tenant" }, {"tenant" : "Test Tenant" }),
184
+ ({"tenant_group" : "Test Tenant Group" }, {"tenant_group" : "test-tenant-group" }),
185
+ ({"time_zone" : "America/Los Angeles" }, {"time_zone" : "America/Los_Angeles" }),
186
+ ({"virtual_machine" : "Test VM 100" }, {"virtual_machine" : "Test VM 100" }),
187
+ ({"vlan" : "Test VLAN" }, {"vlan" : "Test VLAN" }),
188
+ ({"vlan_group" : "Test VLAN Group" }, {"vlan_group" : "test-vlan-group" }),
189
+ ({"vlan_role" : "Access Role" }, {"vlan_role" : "Access Role" }),
190
+ ({"vrf" : "Test VRF" }, {"vrf" : "Test VRF" }),
191
+ ],
192
+ )
193
+ def test_normalize_data_returns_correct_data (mock_netbox_module , before , after ):
194
+ norm_data = mock_netbox_module ._normalize_data (before )
223
195
224
- assert norm_data == norm_data_expected
196
+ assert norm_data == after
225
197
226
198
227
199
def test_to_slug_returns_valid_slug (mock_netbox_module ):
@@ -374,6 +346,7 @@ def test_update_netbox_object_with_changes_check_mode_true(
374
346
"status" : "Provisioning" ,
375
347
"status" : "Deprovisioning" ,
376
348
"status" : "Decommissioned" ,
349
+ "status" : 1 ,
377
350
},
378
351
{
379
352
"status" : 1 ,
@@ -382,6 +355,7 @@ def test_update_netbox_object_with_changes_check_mode_true(
382
355
"status" : 3 ,
383
356
"status" : 0 ,
384
357
"status" : 5 ,
358
+ "status" : 1 ,
385
359
},
386
360
),
387
361
(
@@ -393,8 +367,10 @@ def test_update_netbox_object_with_changes_check_mode_true(
393
367
"status" : "Staged" ,
394
368
"status" : "Failed" ,
395
369
"status" : "Inventory" ,
370
+ "status" : 5 ,
396
371
"face" : "Front" ,
397
372
"face" : "Rear" ,
373
+ "face" : 1 ,
398
374
},
399
375
{
400
376
"status" : 1 ,
@@ -405,6 +381,7 @@ def test_update_netbox_object_with_changes_check_mode_true(
405
381
"status" : 5 ,
406
382
"face" : 0 ,
407
383
"face" : 1 ,
384
+ "face" : 1 ,
408
385
},
409
386
),
410
387
(
@@ -419,8 +396,9 @@ def test_update_netbox_object_with_changes_check_mode_true(
419
396
"mode" : "Access" ,
420
397
"mode" : "Tagged" ,
421
398
"mode" : "Tagged all" ,
399
+ "mode" : 100 ,
422
400
},
423
- {"form_factor" : 1000 , "mode" : 100 , "mode" : 200 , "mode" : 300 },
401
+ {"form_factor" : 1000 , "mode" : 100 , "mode" : 200 , "mode" : 300 , "mode" : 100 },
424
402
),
425
403
(
426
404
"ip_addresses" ,
@@ -429,6 +407,7 @@ def test_update_netbox_object_with_changes_check_mode_true(
429
407
"status" : "Reserved" ,
430
408
"status" : "Deprecated" ,
431
409
"status" : "DHCP" ,
410
+ "status" : 1 ,
432
411
"role" : "Loopback" ,
433
412
"role" : "Secondary" ,
434
413
"role" : "Anycast" ,
@@ -437,12 +416,14 @@ def test_update_netbox_object_with_changes_check_mode_true(
437
416
"role" : "HSRP" ,
438
417
"role" : "GLBP" ,
439
418
"role" : "CARP" ,
419
+ "role" : 30 ,
440
420
},
441
421
{
442
422
"status" : 1 ,
443
423
"status" : 2 ,
444
424
"status" : 3 ,
445
425
"status" : 5 ,
426
+ "status" : 1 ,
446
427
"role" : 10 ,
447
428
"role" : 20 ,
448
429
"role" : 30 ,
@@ -451,6 +432,7 @@ def test_update_netbox_object_with_changes_check_mode_true(
451
432
"role" : 42 ,
452
433
"role" : 43 ,
453
434
"role" : 44 ,
435
+ "role" : 30 ,
454
436
},
455
437
),
456
438
(
@@ -460,8 +442,9 @@ def test_update_netbox_object_with_changes_check_mode_true(
460
442
"status" : "Container" ,
461
443
"status" : "Reserved" ,
462
444
"status" : "Deprecated" ,
445
+ "status" : 2 ,
463
446
},
464
- {"status" : 1 , "status" : 0 , "status" : 2 , "status" : 3 },
447
+ {"status" : 1 , "status" : 0 , "status" : 2 , "status" : 3 , "status" : 2 },
465
448
),
466
449
(
467
450
"racks" ,
@@ -478,6 +461,7 @@ def test_update_netbox_object_with_changes_check_mode_true(
478
461
"type" : "4-post Cabinet" ,
479
462
"type" : "Wall-mounted Frame" ,
480
463
"type" : "Wall-mounted Cabinet" ,
464
+ "type" : 1100 ,
481
465
},
482
466
{
483
467
"status" : 3 ,
@@ -492,12 +476,13 @@ def test_update_netbox_object_with_changes_check_mode_true(
492
476
"type" : 300 ,
493
477
"type" : 1000 ,
494
478
"type" : 1100 ,
479
+ "type" : 1100 ,
495
480
},
496
481
),
497
482
(
498
483
"sites" ,
499
- {"status" : "Active" , "status" : "Planned" , "status" : "Retired" },
500
- {"status" : 1 , "status" : 2 , "status" : 4 },
484
+ {"status" : "Active" , "status" : "Planned" , "status" : "Retired" , "status" : 2 },
485
+ {"status" : 1 , "status" : 2 , "status" : 4 , "status" : 2 },
501
486
),
502
487
(
503
488
"virtual_machines" ,
@@ -507,13 +492,19 @@ def test_update_netbox_object_with_changes_check_mode_true(
507
492
"status" : "Staged" ,
508
493
"face" : "Front" ,
509
494
"face" : "Rear" ,
495
+ "face" : 0 ,
510
496
},
511
- {"status" : 0 , "status" : 1 , "status" : 3 , "face" : 0 , "face" : 1 },
497
+ {"status" : 0 , "status" : 1 , "status" : 3 , "face" : 0 , "face" : 1 , "face" : 0 },
512
498
),
513
499
(
514
500
"vlans" ,
515
- {"status" : "Active" , "status" : "Reserved" , "status" : "Deprecated" },
516
- {"status" : 1 , "status" : 2 , "status" : 3 },
501
+ {
502
+ "status" : "Active" ,
503
+ "status" : "Reserved" ,
504
+ "status" : "Deprecated" ,
505
+ "status" : 2 ,
506
+ },
507
+ {"status" : 1 , "status" : 2 , "status" : 3 , "status" : 2 },
517
508
),
518
509
],
519
510
)
0 commit comments