mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-29 03:46:25 -06:00
fix some of the tests
This commit is contained in:
parent
39d083eae7
commit
9d4c83b0ef
@ -442,7 +442,7 @@ class Rack(CreatedUpdatedModel, CustomFieldModel):
|
|||||||
devices = self.devices.select_related('device_type').filter(position__gte=1).exclude(pk__in=exclude)
|
devices = self.devices.select_related('device_type').filter(position__gte=1).exclude(pk__in=exclude)
|
||||||
|
|
||||||
# Initialize the rack unit skeleton
|
# Initialize the rack unit skeleton
|
||||||
units = range(1, self.u_height + 1)
|
units = list(1, self.u_height + 1)
|
||||||
|
|
||||||
# Remove units consumed by installed devices
|
# Remove units consumed by installed devices
|
||||||
for d in devices:
|
for d in devices:
|
||||||
|
@ -64,7 +64,7 @@ class SiteTest(APITestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def test_get_list(self, endpoint='/{}api/dcim/sites/'.format(settings.BASE_PATH)):
|
def test_get_list(self, endpoint='/{}api/dcim/sites/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for i in content:
|
for i in content:
|
||||||
@ -74,7 +74,7 @@ class SiteTest(APITestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_detail(self, endpoint='/{}api/dcim/sites/1/'.format(settings.BASE_PATH)):
|
def test_get_detail(self, endpoint='/{}api/dcim/sites/1/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -83,7 +83,7 @@ class SiteTest(APITestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_site_list_rack(self, endpoint='/{}api/dcim/sites/1/racks/'.format(settings.BASE_PATH)):
|
def test_get_site_list_rack(self, endpoint='/{}api/dcim/sites/1/racks/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for i in json.loads(response.content):
|
for i in json.loads(response.content):
|
||||||
@ -98,7 +98,7 @@ class SiteTest(APITestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_site_list_graphs(self, endpoint='/{}api/dcim/sites/1/graphs/'.format(settings.BASE_PATH)):
|
def test_get_site_list_graphs(self, endpoint='/{}api/dcim/sites/1/graphs/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for i in json.loads(response.content):
|
for i in json.loads(response.content):
|
||||||
@ -158,7 +158,7 @@ class RackTest(APITestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def test_get_list(self, endpoint='/{}api/dcim/racks/'.format(settings.BASE_PATH)):
|
def test_get_list(self, endpoint='/{}api/dcim/racks/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for i in content:
|
for i in content:
|
||||||
@ -172,7 +172,7 @@ class RackTest(APITestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_detail(self, endpoint='/{}api/dcim/racks/1/'.format(settings.BASE_PATH)):
|
def test_get_detail(self, endpoint='/{}api/dcim/racks/1/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -201,7 +201,7 @@ class ManufacturersTest(APITestCase):
|
|||||||
nested_fields = standard_fields
|
nested_fields = standard_fields
|
||||||
|
|
||||||
def test_get_list(self, endpoint='/{}api/dcim/manufacturers/'.format(settings.BASE_PATH)):
|
def test_get_list(self, endpoint='/{}api/dcim/manufacturers/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for i in content:
|
for i in content:
|
||||||
@ -211,7 +211,7 @@ class ManufacturersTest(APITestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_detail(self, endpoint='/{}api/dcim/manufacturers/1/'.format(settings.BASE_PATH)):
|
def test_get_detail(self, endpoint='/{}api/dcim/manufacturers/1/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -249,7 +249,7 @@ class DeviceTypeTest(APITestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def test_get_list(self, endpoint='/{}api/dcim/device-types/'.format(settings.BASE_PATH)):
|
def test_get_list(self, endpoint='/{}api/dcim/device-types/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for i in content:
|
for i in content:
|
||||||
@ -260,7 +260,7 @@ class DeviceTypeTest(APITestCase):
|
|||||||
|
|
||||||
def test_detail_list(self, endpoint='/{}api/dcim/device-types/1/'.format(settings.BASE_PATH)):
|
def test_detail_list(self, endpoint='/{}api/dcim/device-types/1/'.format(settings.BASE_PATH)):
|
||||||
# TODO: details returns list view.
|
# TODO: details returns list view.
|
||||||
# response = self.client.get(endpoint)
|
# response = self.client.get(endpoint).decode("utf-8")
|
||||||
# content = json.loads(response.content)
|
# content = json.loads(response.content)
|
||||||
# self.assertEqual(response.status_code, status.HTTP_200_OK)
|
# self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
# self.assertEqual(
|
# self.assertEqual(
|
||||||
@ -283,7 +283,7 @@ class DeviceRolesTest(APITestCase):
|
|||||||
nested_fields = ['id', 'name', 'slug']
|
nested_fields = ['id', 'name', 'slug']
|
||||||
|
|
||||||
def test_get_list(self, endpoint='/{}api/dcim/device-roles/'.format(settings.BASE_PATH)):
|
def test_get_list(self, endpoint='/{}api/dcim/device-roles/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for i in content:
|
for i in content:
|
||||||
@ -293,7 +293,7 @@ class DeviceRolesTest(APITestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_detail(self, endpoint='/{}api/dcim/device-roles/1/'.format(settings.BASE_PATH)):
|
def test_get_detail(self, endpoint='/{}api/dcim/device-roles/1/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -311,7 +311,7 @@ class PlatformsTest(APITestCase):
|
|||||||
nested_fields = ['id', 'name', 'slug']
|
nested_fields = ['id', 'name', 'slug']
|
||||||
|
|
||||||
def test_get_list(self, endpoint='/{}api/dcim/platforms/'.format(settings.BASE_PATH)):
|
def test_get_list(self, endpoint='/{}api/dcim/platforms/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for i in content:
|
for i in content:
|
||||||
@ -321,7 +321,7 @@ class PlatformsTest(APITestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_detail(self, endpoint='/{}api/dcim/platforms/1/'.format(settings.BASE_PATH)):
|
def test_get_detail(self, endpoint='/{}api/dcim/platforms/1/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -359,7 +359,7 @@ class DeviceTest(APITestCase):
|
|||||||
nested_fields = ['id', 'name', 'display_name']
|
nested_fields = ['id', 'name', 'display_name']
|
||||||
|
|
||||||
def test_get_list(self, endpoint='/{}api/dcim/devices/'.format(settings.BASE_PATH)):
|
def test_get_list(self, endpoint='/{}api/dcim/devices/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for device in content:
|
for device in content:
|
||||||
@ -424,7 +424,7 @@ class DeviceTest(APITestCase):
|
|||||||
'tenant',
|
'tenant',
|
||||||
]
|
]
|
||||||
|
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
device = content[0]
|
device = content[0]
|
||||||
@ -434,7 +434,7 @@ class DeviceTest(APITestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_detail(self, endpoint='/{}api/dcim/devices/1/'.format(settings.BASE_PATH)):
|
def test_get_detail(self, endpoint='/{}api/dcim/devices/1/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -452,7 +452,7 @@ class ConsoleServerPortsTest(APITestCase):
|
|||||||
nested_fields = ['id', 'device', 'name']
|
nested_fields = ['id', 'device', 'name']
|
||||||
|
|
||||||
def test_get_list(self, endpoint='/{}api/dcim/devices/9/console-server-ports/'.format(settings.BASE_PATH)):
|
def test_get_list(self, endpoint='/{}api/dcim/devices/9/console-server-ports/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for console_port in content:
|
for console_port in content:
|
||||||
@ -474,7 +474,7 @@ class ConsolePortsTest(APITestCase):
|
|||||||
nested_fields = ['id', 'device', 'name']
|
nested_fields = ['id', 'device', 'name']
|
||||||
|
|
||||||
def test_get_list(self, endpoint='/{}api/dcim/devices/1/console-ports/'.format(settings.BASE_PATH)):
|
def test_get_list(self, endpoint='/{}api/dcim/devices/1/console-ports/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for console_port in content:
|
for console_port in content:
|
||||||
@ -492,7 +492,7 @@ class ConsolePortsTest(APITestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_detail(self, endpoint='/{}api/dcim/console-ports/1/'.format(settings.BASE_PATH)):
|
def test_get_detail(self, endpoint='/{}api/dcim/console-ports/1/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -513,7 +513,7 @@ class PowerPortsTest(APITestCase):
|
|||||||
nested_fields = ['id', 'device', 'name']
|
nested_fields = ['id', 'device', 'name']
|
||||||
|
|
||||||
def test_get_list(self, endpoint='/{}api/dcim/devices/1/power-ports/'.format(settings.BASE_PATH)):
|
def test_get_list(self, endpoint='/{}api/dcim/devices/1/power-ports/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for i in content:
|
for i in content:
|
||||||
@ -527,7 +527,7 @@ class PowerPortsTest(APITestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_detail(self, endpoint='/{}api/dcim/power-ports/1/'.format(settings.BASE_PATH)):
|
def test_get_detail(self, endpoint='/{}api/dcim/power-ports/1/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -548,7 +548,7 @@ class PowerOutletsTest(APITestCase):
|
|||||||
nested_fields = ['id', 'device', 'name']
|
nested_fields = ['id', 'device', 'name']
|
||||||
|
|
||||||
def test_get_list(self, endpoint='/{}api/dcim/devices/11/power-outlets/'.format(settings.BASE_PATH)):
|
def test_get_list(self, endpoint='/{}api/dcim/devices/11/power-outlets/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for i in content:
|
for i in content:
|
||||||
@ -598,7 +598,7 @@ class InterfaceTest(APITestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def test_get_list(self, endpoint='/{}api/dcim/devices/1/interfaces/'.format(settings.BASE_PATH)):
|
def test_get_list(self, endpoint='/{}api/dcim/devices/1/interfaces/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for i in content:
|
for i in content:
|
||||||
@ -612,7 +612,7 @@ class InterfaceTest(APITestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_detail(self, endpoint='/{}api/dcim/interfaces/1/'.format(settings.BASE_PATH)):
|
def test_get_detail(self, endpoint='/{}api/dcim/interfaces/1/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -625,18 +625,18 @@ class InterfaceTest(APITestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_graph_list(self, endpoint='/{}api/dcim/interfaces/1/graphs/'.format(settings.BASE_PATH)):
|
def test_get_graph_list(self, endpoint='/{}api/dcim/interfaces/1/graphs/'.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
for i in content:
|
for i in content:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted(i.keys()),
|
sorted(i.keys()),
|
||||||
sorted(SiteTest.graph_fields),
|
sorted(SiteTest.graph_fields),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_get_interface_connections(self, endpoint='/{}api/dcim/interface-connections/4/'
|
def test_get_interface_connections(self, endpoint='/{}api/dcim/interface-connections/4/'
|
||||||
.format(settings.BASE_PATH)):
|
.format(settings.BASE_PATH)):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -658,7 +658,7 @@ class RelatedConnectionsTest(APITestCase):
|
|||||||
|
|
||||||
def test_get_list(self, endpoint=('/{}api/dcim/related-connections/?peer-device=test1-edge1&peer-interface=xe-0/0/3'
|
def test_get_list(self, endpoint=('/{}api/dcim/related-connections/?peer-device=test1-edge1&peer-interface=xe-0/0/3'
|
||||||
.format(settings.BASE_PATH))):
|
.format(settings.BASE_PATH))):
|
||||||
response = self.client.get(endpoint)
|
response = self.client.get(endpoint).decode("utf-8")
|
||||||
content = json.loads(response.content)
|
content = json.loads(response.content)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -5,4 +5,4 @@ import random
|
|||||||
|
|
||||||
charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*(-_=+)'
|
charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*(-_=+)'
|
||||||
random.seed = (os.urandom(2048))
|
random.seed = (os.urandom(2048))
|
||||||
print ''.join(random.choice(charset) for c in range(50))
|
print(''.join(random.choice(charset) for c in range(50)))
|
||||||
|
@ -1 +0,0 @@
|
|||||||
from test_models import *
|
|
Loading…
Reference in New Issue
Block a user