From 7b6a603111eb7c6666498e935f8e859fe6aadbae Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 7 Mar 2024 12:48:57 -0800 Subject: [PATCH] 9856 fix tests / remove debug code --- netbox/utilities/testing/api.py | 34 +++++++++------------------------ 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/netbox/utilities/testing/api.py b/netbox/utilities/testing/api.py index 7445a0edd..1c4d98e2f 100644 --- a/netbox/utilities/testing/api.py +++ b/netbox/utilities/testing/api.py @@ -452,15 +452,13 @@ class APIViewTestCases: fields_string = '' for field in type_class.__strawberry_definition__.fields: - """ - print(f"field_name: {field.name} type: {field.type}") - - if field.name == 'assigned_object': - breakpoint() - pass - """ - - if field.type in (strawberry_django.fields.types.DjangoFileType, strawberry_django.fields.types.DjangoImageType): + if ( + type(field.type) in ( + strawberry_django.fields.types.DjangoFileType, strawberry_django.fields.types.DjangoImageType) or + type(field.type) is StrawberryOptional and field.type.of_type in ( + strawberry_django.fields.types.DjangoFileType, strawberry_django.fields.types.DjangoImageType) + ): + # image / file fields nullable or not... fields_string += f'{field.name} {{ name }}\n' elif type(field.type) is StrawberryList and type(field.type.of_type) is LazyType: # List of related objects (queryset) @@ -471,22 +469,8 @@ class APIViewTestCases: elif type(field.type) is StrawberryUnion: # this would require a fragment query continue - elif field.type is strawberry_django.fields.types.DjangoModelType: - print("DjangoModelType") - 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 type(field.type) is StrawberryOptional and type(field.type.of_type) is LazyType: + fields_string += f'{field.name} {{ id }}\n' elif hasattr(field, 'is_relation') and field.is_relation: # Note: StrawberryField types do not have is_relation fields_string += f'{field.name} {{ id }}\n'