7961 update tests

This commit is contained in:
Arthur 2022-10-21 09:52:46 -07:00
parent a9ce58538d
commit 5fbcdc721c
4 changed files with 335 additions and 0 deletions

View File

@ -50,6 +50,13 @@ class RegionTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
"Region 6,region-6,Sixth region",
)
cls.csv_update_data = (
"name,description",
"Region 7,Fourth region7",
"Region 8,Fifth region8",
"Region 9,Sixth region9",
)
cls.bulk_edit_data = {
'description': 'New description',
}
@ -87,6 +94,13 @@ class SiteGroupTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
"Site Group 6,site-group-6,Sixth site group",
)
cls.csv_update_data = (
"name,description",
"Site Group 7,Fourth site group7",
"Site Group 8,Fifth site group8",
"Site Group 9,Sixth site group9",
)
cls.bulk_edit_data = {
'description': 'New description',
}
@ -156,6 +170,13 @@ class SiteTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"Site 6,site-6,staging",
)
cls.csv_update_data = (
"name,status",
"Site 7,staging",
"Site 8,planned",
"Site 9,active",
)
cls.bulk_edit_data = {
'status': SiteStatusChoices.STATUS_PLANNED,
'region': regions[1].pk,
@ -202,6 +223,13 @@ class LocationTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
"Site 1,Tenant 1,Location 6,location-6,planned,Sixth location",
)
cls.csv_update_data = (
"name,description",
"Location 7,Fourth location7",
"Location 8,Fifth location8",
"Location 9,Sixth location9",
)
cls.bulk_edit_data = {
'description': 'New description',
}
@ -236,6 +264,13 @@ class RackRoleTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
"Rack Role 6,rack-role-6,0000ff",
)
cls.csv_update_data = (
"name,description",
"Rack Role 7,New description7",
"Rack Role 8,New description8",
"Rack Role 9,New description9",
)
cls.bulk_edit_data = {
'color': '00ff00',
'description': 'New description',
@ -283,6 +318,13 @@ class RackReservationTestCase(ViewTestCases.PrimaryObjectViewTestCase):
'Site 1,Location 1,Rack 1,"16,17,18",Reservation 3',
)
cls.csv_update_data = (
'description',
'New description1',
'New description2',
'New description3',
)
cls.bulk_edit_data = {
'user': user3.pk,
'tenant': None,
@ -351,6 +393,13 @@ class RackTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"Site 2,Location 2,Rack 6,active,19,42",
)
cls.csv_update_data = (
"name, status",
f"Rack 7,{RackStatusChoices.STATUS_DEPRECATED}",
f"Rack 8,{RackStatusChoices.STATUS_DEPRECATED}",
f"Rack 9,{RackStatusChoices.STATUS_DEPRECATED}",
)
cls.bulk_edit_data = {
'site': sites[1].pk,
'location': locations[1].pk,
@ -405,6 +454,13 @@ class ManufacturerTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
"Manufacturer 6,manufacturer-6,Sixth manufacturer",
)
cls.csv_update_data = (
"name,description",
"Manufacturer 7,Fourth manufacturer7",
"Manufacturer 8,Fifth manufacturer8",
"Manufacturer 9,Sixth manufacturer9",
)
cls.bulk_edit_data = {
'description': 'New description',
}
@ -1468,6 +1524,13 @@ class DeviceRoleTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
"Device Role 6,device-role-6,0000ff",
)
cls.csv_update_data = (
"name,description",
"Device Role 7,New description7",
"Device Role 8,New description8",
"Device Role 9,New description9",
)
cls.bulk_edit_data = {
'color': '00ff00',
'description': 'New description',
@ -1507,6 +1570,13 @@ class PlatformTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
"Platform 6,platform-6,Sixth platform",
)
cls.csv_update_data = (
"name,description",
"Platform 7,Fourth platform7",
"Platform 8,Fifth platform8",
"Platform 9,Sixth platform9",
)
cls.bulk_edit_data = {
'napalm_driver': 'ios',
'description': 'New description',
@ -1595,6 +1665,13 @@ class DeviceTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"Device Role 1,Manufacturer 1,Device Type 1,active,Device 6,Site 1,Location 1,Rack 1,30,front,Virtual Chassis 1,3,30",
)
cls.csv_update_data = (
"status",
f"{DeviceStatusChoices.STATUS_DECOMMISSIONING}",
f"{DeviceStatusChoices.STATUS_DECOMMISSIONING}",
f"{DeviceStatusChoices.STATUS_DECOMMISSIONING}",
)
cls.bulk_edit_data = {
'device_type': devicetypes[1].pk,
'device_role': deviceroles[1].pk,
@ -1815,6 +1892,13 @@ class ModuleTestCase(
"Device 2,Module Bay 3,Module Type 3,C,C",
)
cls.csv_update_data = (
"module_type",
"Module Type 2",
"Module Type 3",
"Module Type 1",
)
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_module_component_replication(self):
self.add_permissions('dcim.add_module')
@ -1932,6 +2016,13 @@ class ConsolePortTestCase(ViewTestCases.DeviceComponentViewTestCase):
"Device 1,Console Port 6",
)
cls.csv_update_data = (
"name,description",
"Console Port 7,New description7",
"Console Port 8,New description8",
"Console Port 9,New description9",
)
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_trace(self):
consoleport = ConsolePort.objects.first()
@ -1989,6 +2080,13 @@ class ConsoleServerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
"Device 1,Console Server Port 6",
)
cls.csv_data = (
"name,description",
"Console Server Port 7,New description 7",
"Console Server Port 8,New description 8",
"Console Server Port 9,New description 9",
)
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_trace(self):
consoleserverport = ConsoleServerPort.objects.first()
@ -2052,6 +2150,13 @@ class PowerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
"Device 1,Power Port 6",
)
cls.csv_update_data = (
"name,description",
"Power Port 7,New description7",
"Power Port 8,New description8",
"Power Port 9,New description9",
)
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_trace(self):
powerport = PowerPort.objects.first()
@ -2121,6 +2226,13 @@ class PowerOutletTestCase(ViewTestCases.DeviceComponentViewTestCase):
"Device 1,Power Outlet 6",
)
cls.csv_update_data = (
"name,description",
"Power Outlet 7,New description7",
"Power Outlet 8,New description8",
"Power Outlet 9,New description9",
)
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_trace(self):
poweroutlet = PowerOutlet.objects.first()
@ -2247,6 +2359,13 @@ class InterfaceTestCase(ViewTestCases.DeviceComponentViewTestCase):
f"Device 1,Interface 6,1000base-t,{vrfs[0].pk},pse,type1-ieee802.3af",
)
cls.csv_update_data = (
f"name,description",
f"Interface 7,New description7",
f"Interface 8,New description8",
f"Interface 9,New description9",
)
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_trace(self):
interface1, interface2 = Interface.objects.all()[:2]
@ -2313,6 +2432,13 @@ class FrontPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
"Device 1,Front Port 6,8p8c,Rear Port 6,1",
)
cls.csv_update_data = (
"name,description",
"Front Port 7,New description7",
"Front Port 8,New description8",
"Front Port 9,New description9",
)
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_trace(self):
frontport = FrontPort.objects.first()
@ -2372,6 +2498,13 @@ class RearPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
"Device 1,Rear Port 6,8p8c,1",
)
cls.csv_update_data = (
"name,description",
"Rear Port 7,New description7",
"Rear Port 8,New description8",
"Rear Port 9,New description9",
)
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_trace(self):
rearport = RearPort.objects.first()
@ -2426,6 +2559,13 @@ class ModuleBayTestCase(ViewTestCases.DeviceComponentViewTestCase):
"Device 1,Module Bay 6",
)
cls.csv_update_data = (
"name,description",
"Module Bay 7,New description7",
"Module Bay 8,New description8",
"Module Bay 9,New description9",
)
class DeviceBayTestCase(ViewTestCases.DeviceComponentViewTestCase):
model = DeviceBay
@ -2471,6 +2611,13 @@ class DeviceBayTestCase(ViewTestCases.DeviceComponentViewTestCase):
"Device 1,Device Bay 6",
)
cls.csv_update_data = (
"name,description",
"Device Bay 7,New description7",
"Device Bay 8,New description8",
"Device Bay 9,New description9",
)
class InventoryItemTestCase(ViewTestCases.DeviceComponentViewTestCase):
model = InventoryItem
@ -2533,6 +2680,13 @@ class InventoryItemTestCase(ViewTestCases.DeviceComponentViewTestCase):
"Device 1,Inventory Item 6,Inventory Item 3",
)
cls.csv_update_data = (
"name,description",
"Inventory Item 7,New description7",
"Inventory Item 8,New description8",
"Inventory Item 9,New description9",
)
class InventoryItemRoleTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
model = InventoryItemRole
@ -2563,6 +2717,13 @@ class InventoryItemRoleTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
"Inventory Item Role 6,inventory-item-role-6,0000ff",
)
cls.csv_update_data = (
"name,description",
"Inventory Item Role 7,New description7",
"Inventory Item Role 8,New description8",
"Inventory Item Role 9,New description9",
)
cls.bulk_edit_data = {
'color': '00ff00',
'description': 'New description',
@ -2643,6 +2804,13 @@ class CableTestCase(
"Device 3,dcim.interface,Interface 3,Device 4,dcim.interface,Interface 3",
)
cls.csv_update_data = (
"label,color",
"New label7,00ff00",
"New label8,00ff00",
"New label9,00ff00",
)
cls.bulk_edit_data = {
'type': CableTypeChoices.TYPE_CAT5E,
'status': LinkStatusChoices.STATUS_CONNECTED,
@ -2726,6 +2894,13 @@ class VirtualChassisTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"VC6,Domain 6,Device 12",
)
cls.csv_update_data = (
"name,domain",
"VC7,Domain 7",
"VC8,Domain 8",
"VC9,Domain 9",
)
cls.bulk_edit_data = {
'domain': 'domain-x',
}
@ -2772,6 +2947,13 @@ class PowerPanelTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"Site 1,Location 1,Power Panel 6",
)
cls.csv_update_data = (
"name",
"Power Panel 7",
"Power Panel 8",
"Power Panel 9",
)
cls.bulk_edit_data = {
'site': sites[1].pk,
'location': locations[1].pk,
@ -2828,6 +3010,13 @@ class PowerFeedTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"Site 1,Power Panel 1,Power Feed 6,active,primary,ac,single-phase,120,20,80",
)
cls.csv_update_data = (
"name,status",
f"Power Feed 7,{PowerFeedStatusChoices.STATUS_PLANNED}",
f"Power Feed 8,{PowerFeedStatusChoices.STATUS_PLANNED}",
f"Power Feed 9,{PowerFeedStatusChoices.STATUS_PLANNED}",
)
cls.bulk_edit_data = {
'power_panel': powerpanels[1].pk,
'rack': racks[1].pk,

View File

@ -47,6 +47,14 @@ class CustomFieldTestCase(ViewTestCases.PrimaryObjectViewTestCase):
'field7,Field 7,object,dcim.site,dcim.region,100,exact,,,,,read-write',
)
cls.csv_data = (
'name,label',
'field8,Field 8',
'field9,Field 9',
'field10,Field 10',
'field11,Field 11',
)
cls.bulk_edit_data = {
'required': True,
'weight': 200,
@ -83,6 +91,13 @@ class CustomLinkTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"Custom Link 6,dcim.site,False,100,blue,Link 6,http://exmaple.com/?6",
)
cls.csv_update_data = (
"name",
"Custom Link 7",
"Custom Link 8",
"Custom Link 9",
)
cls.bulk_edit_data = {
'button_class': CustomLinkButtonClassChoices.CYAN,
'enabled': False,
@ -117,6 +132,13 @@ class ExportTemplateTestCase(ViewTestCases.PrimaryObjectViewTestCase):
f"Export Template 6,dcim.site,{TEMPLATE_CODE}",
)
cls.csv_update_data = (
"name",
f"Export Template 7",
f"Export Template 8",
f"Export Template 9",
)
cls.bulk_edit_data = {
'mime_type': 'text/html',
'file_extension': 'html',
@ -159,6 +181,13 @@ class WebhookTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"Webhook 6,dcim.site,True,http://example.com/?6,GET,application/json",
)
cls.csv_update_data = (
"name",
"Webhook 7",
"Webhook 8",
"Webhook 9",
)
cls.bulk_edit_data = {
'enabled': False,
'type_create': False,
@ -194,6 +223,13 @@ class TagTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
"Tag 6,tag-6,0000ff,Sixth tag",
)
cls.csv_update_data = (
"name,description",
"Tag 7,Fourth tag7",
"Tag 8,Fifth tag8",
"Tag 9,Sixth tag9",
)
cls.bulk_edit_data = {
'color': '00ff00',
}

View File

@ -60,6 +60,13 @@ class ASNTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"4200000002,RFC 6996",
)
cls.csv_update_data = (
"description",
"New description1",
"New description2",
"New description3",
)
cls.bulk_edit_data = {
'rir': rirs[1].pk,
'description': 'Next description',
@ -102,6 +109,13 @@ class VRFTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"VRF 6",
)
cls.csv_update_data = (
"name",
"VRF 7",
"VRF 8",
"VRF 9",
)
cls.bulk_edit_data = {
'tenant': tenants[1].pk,
'enforce_unique': False,
@ -143,6 +157,13 @@ class RouteTargetTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"65000:1006,,No tenant",
)
cls.csv_update_data = (
"name,description",
"65000:1007,New description1",
"65000:1008,New description2",
"65000:1009,New description3",
)
cls.bulk_edit_data = {
'tenant': tenants[1].pk,
'description': 'New description',
@ -178,6 +199,13 @@ class RIRTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
"RIR 6,rir-6,Sixth RIR",
)
cls.csv_update_data = (
"name,description",
"RIR 7,Fourth RIR7",
"RIR 8,Fifth RIR8",
"RIR 9,Sixth RIR9",
)
cls.bulk_edit_data = {
'description': 'New description',
}
@ -218,6 +246,13 @@ class AggregateTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"10.6.0.0/16,RIR 1",
)
cls.csv_update_data = (
"description",
"New description1",
"New description2",
"New description3",
)
cls.bulk_edit_data = {
'rir': rirs[1].pk,
'date_added': datetime.date(2020, 1, 1),
@ -269,6 +304,13 @@ class RoleTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
"Role 6,role-6,1000",
)
cls.csv_update_data = (
"name,description",
"Role 7,New description7",
"Role 8,New description8",
"Role 9,New description9",
)
cls.bulk_edit_data = {
'description': 'New description',
}
@ -326,6 +368,13 @@ class PrefixTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"VRF 1,10.6.0.0/16,active",
)
cls.csv_update_data = (
"description,status",
f",New description 7,{PrefixStatusChoices.STATUS_RESERVED}",
f",New description 8,{PrefixStatusChoices.STATUS_RESERVED}",
f",New description 9,{PrefixStatusChoices.STATUS_RESERVED}",
)
cls.bulk_edit_data = {
'site': sites[1].pk,
'vrf': vrfs[1].pk,
@ -428,6 +477,13 @@ class IPRangeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"VRF 1,10.3.0.1/16,10.3.9.254/16,active",
)
cls.csv_update_data = (
"description,status",
f"New description 7,{IPRangeStatusChoices.STATUS_RESERVED}",
f"New description 8,{IPRangeStatusChoices.STATUS_RESERVED}",
f"New description 9,{IPRangeStatusChoices.STATUS_RESERVED}",
)
cls.bulk_edit_data = {
'vrf': vrfs[1].pk,
'tenant': None,
@ -494,6 +550,13 @@ class IPAddressTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"VRF 1,192.0.2.6/24,active",
)
cls.csv_update_data = (
"description,status",
f"New description 7,{IPAddressStatusChoices.STATUS_RESERVED}",
f"New description 8,{IPAddressStatusChoices.STATUS_RESERVED}",
f"New description 9,{IPAddressStatusChoices.STATUS_RESERVED}",
)
cls.bulk_edit_data = {
'vrf': vrfs[1].pk,
'tenant': None,
@ -535,6 +598,13 @@ class FHRPGroupTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"hsrp,60,,,",
)
cls.csv_update_data = (
"name,description",
"FHRP Group 1,New description 1",
"FHRP Group 2,New description 2",
"FHRP Group 3,New description 3",
)
cls.bulk_edit_data = {
'protocol': FHRPGroupProtocolChoices.PROTOCOL_CARP,
}
@ -576,6 +646,13 @@ class VLANGroupTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
f"VLAN Group 6,vlan-group-6,dcim.site,{sites[1].pk},Sixth VLAN group",
)
cls.csv_data = (
f"name,description",
f"VLAN Group 7,Fourth VLAN group7",
f"VLAN Group 8,Fifth VLAN group8",
f"VLAN Group 9,Sixth VLAN group9",
)
cls.bulk_edit_data = {
'description': 'New description',
}
@ -632,6 +709,13 @@ class VLANTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"106,VLAN106,active",
)
cls.csv_update_data = (
"name,description",
"VLAN107,New description 7",
"VLAN108,New description 8",
"VLAN109,New description 9",
)
cls.bulk_edit_data = {
'site': sites[1].pk,
'group': vlangroups[1].pk,
@ -670,6 +754,13 @@ class ServiceTemplateTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"Service Template 6,tcp,3,Third service template",
)
cls.csv_update_data = (
"name,description",
"Service Template 7,First service template7",
"Service Template 8,Second service template8",
"Service Template 9,Third service template9",
)
cls.bulk_edit_data = {
'protocol': ServiceProtocolChoices.PROTOCOL_UDP,
'ports': '106,107',
@ -715,6 +806,13 @@ class ServiceTestCase(ViewTestCases.PrimaryObjectViewTestCase):
"Device 1,Service 3,udp,3,Third service",
)
cls.csv_update_data = (
"name,description",
"Service 7,First service7",
"Service 8,Second service8",
"Service 9,Third service9",
)
cls.bulk_edit_data = {
'protocol': ServiceProtocolChoices.PROTOCOL_UDP,
'ports': '106,107',
@ -756,6 +854,13 @@ class L2VPNTestCase(ViewTestCases.PrimaryObjectViewTestCase):
'L2VPN 5,l2vpn-5,vxlan,456',
'L2VPN 6,l2vpn-6,vxlan,444',
)
csv_update_data = (
'name,description',
'L2VPN 7,New description 7',
'L2VPN 8,New description 8',
)
bulk_edit_data = {
'description': 'New Description',
}
@ -836,6 +941,8 @@ class L2VPNTerminationTestCase(
"L2VPN 1,Vlan 6",
)
cls.csv_update_data = ()
cls.bulk_edit_data = {}
#

View File

@ -598,6 +598,9 @@ class ViewTestCases:
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_bulk_update_objects_with_permission(self):
if not self.csv_update_data:
return
data = {
'csv': self._get_csv_data(),
}