mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Update tests for tag changes
This commit is contained in:
@ -26,7 +26,7 @@ class ProviderTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'noc_contact': 'noc@example.com',
|
'noc_contact': 'noc@example.com',
|
||||||
'admin_contact': 'admin@example.com',
|
'admin_contact': 'admin@example.com',
|
||||||
'comments': 'Another provider',
|
'comments': 'Another provider',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
@ -106,7 +106,7 @@ class CircuitTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'commit_rate': 1000,
|
'commit_rate': 1000,
|
||||||
'description': 'A new circuit',
|
'description': 'A new circuit',
|
||||||
'comments': 'Some comments',
|
'comments': 'Some comments',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
@ -124,5 +124,4 @@ class CircuitTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'commit_rate': 2000,
|
'commit_rate': 2000,
|
||||||
'description': 'New description',
|
'description': 'New description',
|
||||||
'comments': 'New comments',
|
'comments': 'New comments',
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ class SiteTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'contact_phone': '123-555-9999',
|
'contact_phone': '123-555-9999',
|
||||||
'contact_email': 'hank@stricklandpropane.com',
|
'contact_email': 'hank@stricklandpropane.com',
|
||||||
'comments': 'Test site',
|
'comments': 'Test site',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
@ -202,7 +202,7 @@ class RackReservationTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'user': user3.pk,
|
'user': user3.pk,
|
||||||
'tenant': None,
|
'tenant': None,
|
||||||
'description': 'Rack reservation',
|
'description': 'Rack reservation',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
@ -268,7 +268,7 @@ class RackTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'outer_depth': 500,
|
'outer_depth': 500,
|
||||||
'outer_unit': RackDimensionUnitChoices.UNIT_MILLIMETER,
|
'outer_unit': RackDimensionUnitChoices.UNIT_MILLIMETER,
|
||||||
'comments': 'Some comments',
|
'comments': 'Some comments',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
@ -359,7 +359,7 @@ class DeviceTypeTestCase(
|
|||||||
'is_full_depth': True,
|
'is_full_depth': True,
|
||||||
'subdevice_role': '', # CharField
|
'subdevice_role': '', # CharField
|
||||||
'comments': 'Some comments',
|
'comments': 'Some comments',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
@ -967,7 +967,7 @@ class DeviceTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'vc_position': None,
|
'vc_position': None,
|
||||||
'vc_priority': None,
|
'vc_priority': None,
|
||||||
'comments': 'A new device',
|
'comments': 'A new device',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
'local_context_data': None,
|
'local_context_data': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1001,12 +1001,14 @@ class ConsolePortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
ConsolePort(device=device, name='Console Port 3'),
|
ConsolePort(device=device, name='Console Port 3'),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
tags = cls.create_tags('Alpha', 'Bravo', 'Charlie')
|
||||||
|
|
||||||
cls.form_data = {
|
cls.form_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name': 'Console Port X',
|
'name': 'Console Port X',
|
||||||
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
||||||
'description': 'A console port',
|
'description': 'A console port',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
@ -1016,7 +1018,7 @@ class ConsolePortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
'label_pattern': 'Serial[3-5]',
|
'label_pattern': 'Serial[3-5]',
|
||||||
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
||||||
'description': 'A console port',
|
'description': 'A console port',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
@ -1045,12 +1047,14 @@ class ConsoleServerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
ConsoleServerPort(device=device, name='Console Server Port 3'),
|
ConsoleServerPort(device=device, name='Console Server Port 3'),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
tags = cls.create_tags('Alpha', 'Bravo', 'Charlie')
|
||||||
|
|
||||||
cls.form_data = {
|
cls.form_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name': 'Console Server Port X',
|
'name': 'Console Server Port X',
|
||||||
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
||||||
'description': 'A console server port',
|
'description': 'A console server port',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
@ -1058,7 +1062,7 @@ class ConsoleServerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
'name_pattern': 'Console Server Port [4-6]',
|
'name_pattern': 'Console Server Port [4-6]',
|
||||||
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
||||||
'description': 'A console server port',
|
'description': 'A console server port',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
@ -1087,6 +1091,8 @@ class PowerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
PowerPort(device=device, name='Power Port 3'),
|
PowerPort(device=device, name='Power Port 3'),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
tags = cls.create_tags('Alpha', 'Bravo', 'Charlie')
|
||||||
|
|
||||||
cls.form_data = {
|
cls.form_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name': 'Power Port X',
|
'name': 'Power Port X',
|
||||||
@ -1094,7 +1100,7 @@ class PowerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
'maximum_draw': 100,
|
'maximum_draw': 100,
|
||||||
'allocated_draw': 50,
|
'allocated_draw': 50,
|
||||||
'description': 'A power port',
|
'description': 'A power port',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
@ -1104,7 +1110,7 @@ class PowerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
'maximum_draw': 100,
|
'maximum_draw': 100,
|
||||||
'allocated_draw': 50,
|
'allocated_draw': 50,
|
||||||
'description': 'A power port',
|
'description': 'A power port',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
@ -1141,6 +1147,8 @@ class PowerOutletTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
PowerOutlet(device=device, name='Power Outlet 3', power_port=powerports[0]),
|
PowerOutlet(device=device, name='Power Outlet 3', power_port=powerports[0]),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
tags = cls.create_tags('Alpha', 'Bravo', 'Charlie')
|
||||||
|
|
||||||
cls.form_data = {
|
cls.form_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name': 'Power Outlet X',
|
'name': 'Power Outlet X',
|
||||||
@ -1148,7 +1156,7 @@ class PowerOutletTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
'power_port': powerports[1].pk,
|
'power_port': powerports[1].pk,
|
||||||
'feed_leg': PowerOutletFeedLegChoices.FEED_LEG_B,
|
'feed_leg': PowerOutletFeedLegChoices.FEED_LEG_B,
|
||||||
'description': 'A power outlet',
|
'description': 'A power outlet',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
@ -1158,7 +1166,7 @@ class PowerOutletTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
'power_port': powerports[1].pk,
|
'power_port': powerports[1].pk,
|
||||||
'feed_leg': PowerOutletFeedLegChoices.FEED_LEG_B,
|
'feed_leg': PowerOutletFeedLegChoices.FEED_LEG_B,
|
||||||
'description': 'A power outlet',
|
'description': 'A power outlet',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
@ -1202,6 +1210,8 @@ class InterfaceTestCase(
|
|||||||
)
|
)
|
||||||
VLAN.objects.bulk_create(vlans)
|
VLAN.objects.bulk_create(vlans)
|
||||||
|
|
||||||
|
tags = cls.create_tags('Alpha', 'Bravo', 'Charlie')
|
||||||
|
|
||||||
cls.form_data = {
|
cls.form_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'virtual_machine': None,
|
'virtual_machine': None,
|
||||||
@ -1216,7 +1226,7 @@ class InterfaceTestCase(
|
|||||||
'mode': InterfaceModeChoices.MODE_TAGGED,
|
'mode': InterfaceModeChoices.MODE_TAGGED,
|
||||||
'untagged_vlan': vlans[0].pk,
|
'untagged_vlan': vlans[0].pk,
|
||||||
'tagged_vlans': [v.pk for v in vlans[1:4]],
|
'tagged_vlans': [v.pk for v in vlans[1:4]],
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
@ -1232,7 +1242,7 @@ class InterfaceTestCase(
|
|||||||
'mode': InterfaceModeChoices.MODE_TAGGED,
|
'mode': InterfaceModeChoices.MODE_TAGGED,
|
||||||
'untagged_vlan': vlans[0].pk,
|
'untagged_vlan': vlans[0].pk,
|
||||||
'tagged_vlans': [v.pk for v in vlans[1:4]],
|
'tagged_vlans': [v.pk for v in vlans[1:4]],
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
@ -1279,6 +1289,8 @@ class FrontPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
FrontPort(device=device, name='Front Port 3', rear_port=rearports[2]),
|
FrontPort(device=device, name='Front Port 3', rear_port=rearports[2]),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
tags = cls.create_tags('Alpha', 'Bravo', 'Charlie')
|
||||||
|
|
||||||
cls.form_data = {
|
cls.form_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name': 'Front Port X',
|
'name': 'Front Port X',
|
||||||
@ -1286,7 +1298,7 @@ class FrontPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
'rear_port': rearports[3].pk,
|
'rear_port': rearports[3].pk,
|
||||||
'rear_port_position': 1,
|
'rear_port_position': 1,
|
||||||
'description': 'New description',
|
'description': 'New description',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
@ -1297,7 +1309,7 @@ class FrontPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
'{}:1'.format(rp.pk) for rp in rearports[3:6]
|
'{}:1'.format(rp.pk) for rp in rearports[3:6]
|
||||||
],
|
],
|
||||||
'description': 'New description',
|
'description': 'New description',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
@ -1326,13 +1338,15 @@ class RearPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
RearPort(device=device, name='Rear Port 3'),
|
RearPort(device=device, name='Rear Port 3'),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
tags = cls.create_tags('Alpha', 'Bravo', 'Charlie')
|
||||||
|
|
||||||
cls.form_data = {
|
cls.form_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name': 'Rear Port X',
|
'name': 'Rear Port X',
|
||||||
'type': PortTypeChoices.TYPE_8P8C,
|
'type': PortTypeChoices.TYPE_8P8C,
|
||||||
'positions': 3,
|
'positions': 3,
|
||||||
'description': 'A rear port',
|
'description': 'A rear port',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
@ -1341,7 +1355,7 @@ class RearPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
'type': PortTypeChoices.TYPE_8P8C,
|
'type': PortTypeChoices.TYPE_8P8C,
|
||||||
'positions': 3,
|
'positions': 3,
|
||||||
'description': 'A rear port',
|
'description': 'A rear port',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
@ -1373,18 +1387,20 @@ class DeviceBayTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
DeviceBay(device=device, name='Device Bay 3'),
|
DeviceBay(device=device, name='Device Bay 3'),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
tags = cls.create_tags('Alpha', 'Bravo', 'Charlie')
|
||||||
|
|
||||||
cls.form_data = {
|
cls.form_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name': 'Device Bay X',
|
'name': 'Device Bay X',
|
||||||
'description': 'A device bay',
|
'description': 'A device bay',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name_pattern': 'Device Bay [4-6]',
|
'name_pattern': 'Device Bay [4-6]',
|
||||||
'description': 'A device bay',
|
'description': 'A device bay',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
@ -1413,6 +1429,8 @@ class InventoryItemTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
InventoryItem(device=device, name='Inventory Item 3'),
|
InventoryItem(device=device, name='Inventory Item 3'),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
tags = cls.create_tags('Alpha', 'Bravo', 'Charlie')
|
||||||
|
|
||||||
cls.form_data = {
|
cls.form_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'manufacturer': manufacturer.pk,
|
'manufacturer': manufacturer.pk,
|
||||||
@ -1423,7 +1441,7 @@ class InventoryItemTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
'serial': '123ABC',
|
'serial': '123ABC',
|
||||||
'asset_tag': 'ABC123',
|
'asset_tag': 'ABC123',
|
||||||
'description': 'An inventory item',
|
'description': 'An inventory item',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
@ -1435,7 +1453,7 @@ class InventoryItemTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
'part_id': '123456',
|
'part_id': '123456',
|
||||||
'serial': '123ABC',
|
'serial': '123ABC',
|
||||||
'description': 'An inventory item',
|
'description': 'An inventory item',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
@ -1513,7 +1531,7 @@ class CableTestCase(
|
|||||||
'color': 'c0c0c0',
|
'color': 'c0c0c0',
|
||||||
'length': 100,
|
'length': 100,
|
||||||
'length_unit': CableLengthUnitChoices.UNIT_FOOT,
|
'length_unit': CableLengthUnitChoices.UNIT_FOOT,
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
@ -1626,7 +1644,7 @@ class PowerPanelTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'site': sites[1].pk,
|
'site': sites[1].pk,
|
||||||
'rack_group': rackgroups[1].pk,
|
'rack_group': rackgroups[1].pk,
|
||||||
'name': 'Power Panel X',
|
'name': 'Power Panel X',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
@ -1680,7 +1698,7 @@ class PowerFeedTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'amperage': 100,
|
'amperage': 100,
|
||||||
'max_utilization': 50,
|
'max_utilization': 50,
|
||||||
'comments': 'New comments',
|
'comments': 'New comments',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
|
|
||||||
# Connection
|
# Connection
|
||||||
'cable': None,
|
'cable': None,
|
||||||
|
@ -33,7 +33,7 @@ class VRFTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'tenant': tenants[0].pk,
|
'tenant': tenants[0].pk,
|
||||||
'enforce_unique': True,
|
'enforce_unique': True,
|
||||||
'description': 'A new VRF',
|
'description': 'A new VRF',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
@ -100,7 +100,7 @@ class AggregateTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'rir': rirs[1].pk,
|
'rir': rirs[1].pk,
|
||||||
'date_added': datetime.date(2020, 1, 1),
|
'date_added': datetime.date(2020, 1, 1),
|
||||||
'description': 'A new aggregate',
|
'description': 'A new aggregate',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
@ -183,7 +183,7 @@ class PrefixTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'role': roles[1].pk,
|
'role': roles[1].pk,
|
||||||
'is_pool': True,
|
'is_pool': True,
|
||||||
'description': 'A new prefix',
|
'description': 'A new prefix',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
@ -232,7 +232,7 @@ class IPAddressTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'nat_inside': None,
|
'nat_inside': None,
|
||||||
'dns_name': 'example',
|
'dns_name': 'example',
|
||||||
'description': 'A new IP address',
|
'description': 'A new IP address',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
@ -320,7 +320,7 @@ class VLANTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'status': VLANStatusChoices.STATUS_RESERVED,
|
'status': VLANStatusChoices.STATUS_RESERVED,
|
||||||
'role': roles[1].pk,
|
'role': roles[1].pk,
|
||||||
'description': 'A new VLAN',
|
'description': 'A new VLAN',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
@ -376,7 +376,7 @@ class ServiceTestCase(
|
|||||||
'port': 999,
|
'port': 999,
|
||||||
'ipaddresses': [],
|
'ipaddresses': [],
|
||||||
'description': 'A new service',
|
'description': 'A new service',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
|
@ -55,7 +55,7 @@ class TenantTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'group': tenant_groups[1].pk,
|
'group': tenant_groups[1].pk,
|
||||||
'description': 'A new tenant',
|
'description': 'A new tenant',
|
||||||
'comments': 'Some comments',
|
'comments': 'Some comments',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
|
@ -14,7 +14,14 @@ def post_data(data):
|
|||||||
if value is None:
|
if value is None:
|
||||||
ret[key] = ''
|
ret[key] = ''
|
||||||
elif type(value) in (list, tuple):
|
elif type(value) in (list, tuple):
|
||||||
ret[key] = value
|
if value and hasattr(value[0], 'pk'):
|
||||||
|
# Value is a list of instances
|
||||||
|
ret[key] = [v.pk for v in value]
|
||||||
|
else:
|
||||||
|
ret[key] = value
|
||||||
|
elif hasattr(value, 'pk'):
|
||||||
|
# Value is an instance
|
||||||
|
ret[key] = value.pk
|
||||||
else:
|
else:
|
||||||
ret[key] = str(value)
|
ret[key] = str(value)
|
||||||
|
|
||||||
|
@ -5,8 +5,10 @@ from django.db.models import ForeignKey, ManyToManyField
|
|||||||
from django.forms.models import model_to_dict
|
from django.forms.models import model_to_dict
|
||||||
from django.test import Client, TestCase as _TestCase, override_settings
|
from django.test import Client, TestCase as _TestCase, override_settings
|
||||||
from django.urls import reverse, NoReverseMatch
|
from django.urls import reverse, NoReverseMatch
|
||||||
|
from django.utils.text import slugify
|
||||||
from netaddr import IPNetwork
|
from netaddr import IPNetwork
|
||||||
|
|
||||||
|
from extras.models import Tag
|
||||||
from users.models import ObjectPermission
|
from users.models import ObjectPermission
|
||||||
from utilities.permissions import resolve_permission_ct
|
from utilities.permissions import resolve_permission_ct
|
||||||
from .utils import disable_warnings, post_data
|
from .utils import disable_warnings, post_data
|
||||||
@ -48,7 +50,7 @@ class TestCase(_TestCase):
|
|||||||
obj_perm.object_types.add(ct)
|
obj_perm.object_types.add(ct)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Convenience methods
|
# Custom assertions
|
||||||
#
|
#
|
||||||
|
|
||||||
def assertHttpStatus(self, response, expected_status):
|
def assertHttpStatus(self, response, expected_status):
|
||||||
@ -75,7 +77,7 @@ class TestCase(_TestCase):
|
|||||||
|
|
||||||
# TODO: Differentiate between tags assigned to the instance and a M2M field for tags (ex: ConfigContext)
|
# TODO: Differentiate between tags assigned to the instance and a M2M field for tags (ex: ConfigContext)
|
||||||
if key == 'tags':
|
if key == 'tags':
|
||||||
model_dict[key] = ','.join(sorted([tag.name for tag in value]))
|
model_dict[key] = sorted(value)
|
||||||
|
|
||||||
# Convert ManyToManyField to list of instance PKs
|
# Convert ManyToManyField to list of instance PKs
|
||||||
elif model_dict[key] and type(value) in (list, tuple) and hasattr(value[0], 'pk'):
|
elif model_dict[key] and type(value) in (list, tuple) and hasattr(value[0], 'pk'):
|
||||||
@ -102,6 +104,19 @@ class TestCase(_TestCase):
|
|||||||
|
|
||||||
self.assertDictEqual(model_dict, relevant_data)
|
self.assertDictEqual(model_dict, relevant_data)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Convenience methods
|
||||||
|
#
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def create_tags(cls, *names):
|
||||||
|
"""
|
||||||
|
Create and return a Tag instance for each name given.
|
||||||
|
"""
|
||||||
|
tags = [Tag(name=name, slug=slugify(name)) for name in names]
|
||||||
|
Tag.objects.bulk_create(tags)
|
||||||
|
return tags
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# UI Tests
|
# UI Tests
|
||||||
|
@ -97,7 +97,7 @@ class ClusterTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'tenant': None,
|
'tenant': None,
|
||||||
'site': sites[1].pk,
|
'site': sites[1].pk,
|
||||||
'comments': 'Some comments',
|
'comments': 'Some comments',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
@ -161,7 +161,7 @@ class VirtualMachineTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'memory': 32768,
|
'memory': 32768,
|
||||||
'disk': 4000,
|
'disk': 4000,
|
||||||
'comments': 'Some comments',
|
'comments': 'Some comments',
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': cls.create_tags('Alpha', 'Bravo', 'Charlie'),
|
||||||
'local_context_data': None,
|
'local_context_data': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,6 +228,8 @@ class InterfaceTestCase(
|
|||||||
)
|
)
|
||||||
VLAN.objects.bulk_create(vlans)
|
VLAN.objects.bulk_create(vlans)
|
||||||
|
|
||||||
|
tags = cls.create_tags('Alpha', 'Bravo', 'Charlie')
|
||||||
|
|
||||||
cls.form_data = {
|
cls.form_data = {
|
||||||
'virtual_machine': virtualmachines[1].pk,
|
'virtual_machine': virtualmachines[1].pk,
|
||||||
'name': 'Interface X',
|
'name': 'Interface X',
|
||||||
@ -240,7 +242,7 @@ class InterfaceTestCase(
|
|||||||
'mode': InterfaceModeChoices.MODE_TAGGED,
|
'mode': InterfaceModeChoices.MODE_TAGGED,
|
||||||
'untagged_vlan': vlans[0].pk,
|
'untagged_vlan': vlans[0].pk,
|
||||||
'tagged_vlans': [v.pk for v in vlans[1:4]],
|
'tagged_vlans': [v.pk for v in vlans[1:4]],
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
@ -255,7 +257,7 @@ class InterfaceTestCase(
|
|||||||
'mode': InterfaceModeChoices.MODE_TAGGED,
|
'mode': InterfaceModeChoices.MODE_TAGGED,
|
||||||
'untagged_vlan': vlans[0].pk,
|
'untagged_vlan': vlans[0].pk,
|
||||||
'tagged_vlans': [v.pk for v in vlans[1:4]],
|
'tagged_vlans': [v.pk for v in vlans[1:4]],
|
||||||
'tags': 'Alpha,Bravo,Charlie',
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
|
Reference in New Issue
Block a user