1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

9856 fix tests / remove debug code

This commit is contained in:
Arthur
2024-03-07 12:48:57 -08:00
parent 133d6bfcb3
commit 7b6a603111

View File

@ -452,15 +452,13 @@ class APIViewTestCases:
fields_string = '' fields_string = ''
for field in type_class.__strawberry_definition__.fields: for field in type_class.__strawberry_definition__.fields:
""" if (
print(f"field_name: {field.name} type: {field.type}") type(field.type) in (
strawberry_django.fields.types.DjangoFileType, strawberry_django.fields.types.DjangoImageType) or
if field.name == 'assigned_object': type(field.type) is StrawberryOptional and field.type.of_type in (
breakpoint() strawberry_django.fields.types.DjangoFileType, strawberry_django.fields.types.DjangoImageType)
pass ):
""" # image / file fields nullable or not...
if field.type in (strawberry_django.fields.types.DjangoFileType, strawberry_django.fields.types.DjangoImageType):
fields_string += f'{field.name} {{ name }}\n' fields_string += f'{field.name} {{ name }}\n'
elif type(field.type) is StrawberryList and type(field.type.of_type) is LazyType: elif type(field.type) is StrawberryList and type(field.type.of_type) is LazyType:
# List of related objects (queryset) # List of related objects (queryset)
@ -471,22 +469,8 @@ class APIViewTestCases:
elif type(field.type) is StrawberryUnion: elif type(field.type) is StrawberryUnion:
# this would require a fragment query # this would require a fragment query
continue continue
elif field.type is strawberry_django.fields.types.DjangoModelType: elif type(field.type) is StrawberryOptional and type(field.type.of_type) is LazyType:
print("DjangoModelType") fields_string += f'{field.name} {{ id }}\n'
print("--------------------------")
print(f"{self.model} -> {field.name}")
print("")
# Dynamic fields must specify a subselection
fields_string += f'{field.name} {{ pk }}\n'
elif type(field.type) is StrawberryOptional:
if type(field.type.of_type) is LazyType:
fields_string += f'{field.name} {{ id }}\n'
elif field.type.of_type == strawberry_django.fields.types.DjangoModelType:
print("DjangoModelType")
print("--------------------------")
print(f"{self.model} -> {field.name}")
print("")
fields_string += f'{field.name} {{ pk }}\n'
elif hasattr(field, 'is_relation') and field.is_relation: elif hasattr(field, 'is_relation') and field.is_relation:
# Note: StrawberryField types do not have is_relation # Note: StrawberryField types do not have is_relation
fields_string += f'{field.name} {{ id }}\n' fields_string += f'{field.name} {{ id }}\n'