mirror of
https://github.com/netbox-community/netbox.git
synced 2026-02-04 14:26:25 -06:00
19724 fix tests
This commit is contained in:
@@ -562,6 +562,20 @@ class APIViewTestCases:
|
|||||||
else:
|
else:
|
||||||
fields_string += f'{field.name}\n'
|
fields_string += f'{field.name}\n'
|
||||||
|
|
||||||
|
# Check if this is a list query (ends with '_list')
|
||||||
|
if name.endswith('_list'):
|
||||||
|
# Wrap fields in 'results' for paginated queries
|
||||||
|
query = f"""
|
||||||
|
{{
|
||||||
|
{name}{filter_string} {{
|
||||||
|
results {{
|
||||||
|
{fields_string}
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
"""
|
||||||
|
else:
|
||||||
|
# Single object query (no pagination)
|
||||||
query = f"""
|
query = f"""
|
||||||
{{
|
{{
|
||||||
{name}{filter_string} {{
|
{name}{filter_string} {{
|
||||||
@@ -677,7 +691,7 @@ class APIViewTestCases:
|
|||||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||||
data = json.loads(response.content)
|
data = json.loads(response.content)
|
||||||
self.assertNotIn('errors', data)
|
self.assertNotIn('errors', data)
|
||||||
self.assertEqual(len(data['data'][field_name]), 0)
|
self.assertEqual(len(data['data'][field_name]['results']), 0)
|
||||||
|
|
||||||
# Remove permission constraint
|
# Remove permission constraint
|
||||||
obj_perm.constraints = None
|
obj_perm.constraints = None
|
||||||
@@ -688,7 +702,7 @@ class APIViewTestCases:
|
|||||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||||
data = json.loads(response.content)
|
data = json.loads(response.content)
|
||||||
self.assertNotIn('errors', data)
|
self.assertNotIn('errors', data)
|
||||||
self.assertEqual(len(data['data'][field_name]), self.model.objects.count())
|
self.assertEqual(len(data['data'][field_name]['results']), self.model.objects.count())
|
||||||
|
|
||||||
@override_settings(LOGIN_REQUIRED=True)
|
@override_settings(LOGIN_REQUIRED=True)
|
||||||
def test_graphql_filter_objects(self):
|
def test_graphql_filter_objects(self):
|
||||||
@@ -712,7 +726,7 @@ class APIViewTestCases:
|
|||||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||||
data = json.loads(response.content)
|
data = json.loads(response.content)
|
||||||
self.assertNotIn('errors', data)
|
self.assertNotIn('errors', data)
|
||||||
self.assertGreater(len(data['data'][field_name]), 0)
|
self.assertGreater(len(data['data'][field_name]['results']), 0)
|
||||||
|
|
||||||
class APIViewTestCase(
|
class APIViewTestCase(
|
||||||
GetObjectViewTestCase,
|
GetObjectViewTestCase,
|
||||||
|
|||||||
Reference in New Issue
Block a user