From 64c2371cf716fa69b288b2424b45a5bad07aed4f Mon Sep 17 00:00:00 2001 From: "radoslaw.kowalski" Date: Sun, 7 Jun 2020 12:25:21 +0200 Subject: [PATCH] Add explicit fields = "__all__" to mute warnings in tests --- graphene_django/debug/tests/test_query.py | 5 ++++ graphene_django/filter/tests/test_fields.py | 22 ++++++++++++++ .../tests/test_multiple_model_serializers.py | 2 ++ .../rest_framework/tests/test_mutation.py | 1 + graphene_django/tests/schema.py | 2 ++ graphene_django/tests/test_converter.py | 4 +++ graphene_django/tests/test_query.py | 29 +++++++++++++++++++ graphene_django/tests/test_schema.py | 4 ++- graphene_django/tests/test_types.py | 6 ++++ 9 files changed, 74 insertions(+), 1 deletion(-) diff --git a/graphene_django/debug/tests/test_query.py b/graphene_django/debug/tests/test_query.py index 7255ec6..fcfcd71 100644 --- a/graphene_django/debug/tests/test_query.py +++ b/graphene_django/debug/tests/test_query.py @@ -21,6 +21,7 @@ def test_should_query_field(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class Query(graphene.ObjectType): reporter = graphene.Field(ReporterType) @@ -65,6 +66,7 @@ def test_should_query_nested_field(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class Query(graphene.ObjectType): reporter = graphene.Field(ReporterType) @@ -130,6 +132,7 @@ def test_should_query_list(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class Query(graphene.ObjectType): all_reporters = graphene.List(ReporterType) @@ -172,6 +175,7 @@ def test_should_query_connection(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class Query(graphene.ObjectType): all_reporters = DjangoConnectionField(ReporterType) @@ -220,6 +224,7 @@ def test_should_query_connectionfilter(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class Query(graphene.ObjectType): all_reporters = DjangoFilterConnectionField(ReporterType, fields=["last_name"]) diff --git a/graphene_django/filter/tests/test_fields.py b/graphene_django/filter/tests/test_fields.py index 59cc30b..1e36a9a 100644 --- a/graphene_django/filter/tests/test_fields.py +++ b/graphene_django/filter/tests/test_fields.py @@ -41,17 +41,20 @@ if DJANGO_FILTER_INSTALLED: class Meta: model = Article interfaces = (Node,) + fields = "__all__" filter_fields = ("headline",) class ReporterNode(DjangoObjectType): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class PetNode(DjangoObjectType): class Meta: model = Pet interfaces = (Node,) + fields = "__all__" def get_args(field): @@ -189,6 +192,7 @@ def test_filter_filterset_information_on_meta(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" filter_fields = ["first_name", "articles"] field = DjangoFilterConnectionField(ReporterFilterNode) @@ -201,12 +205,14 @@ def test_filter_filterset_information_on_meta_related(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" filter_fields = ["first_name", "articles"] class ArticleFilterNode(DjangoObjectType): class Meta: model = Article interfaces = (Node,) + fields = "__all__" filter_fields = ["headline", "reporter"] class Query(ObjectType): @@ -233,6 +239,7 @@ def test_filter_filterset_class_filter_fields_exception(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" filterset_class = ReporterFilter filter_fields = ["first_name", "articles"] @@ -247,6 +254,7 @@ def test_filter_filterset_class_information_on_meta(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" filterset_class = ReporterFilter field = DjangoFilterConnectionField(ReporterFilterNode) @@ -269,12 +277,14 @@ def test_filter_filterset_class_information_on_meta_related(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" filterset_class = ReporterFilter class ArticleFilterNode(DjangoObjectType): class Meta: model = Article interfaces = (Node,) + fields = "__all__" filterset_class = ArticleFilter class Query(ObjectType): @@ -294,12 +304,14 @@ def test_filter_filterset_related_results(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" filter_fields = ["first_name", "articles"] class ArticleFilterNode(DjangoObjectType): class Meta: interfaces = (Node,) model = Article + fields = "__all__" filter_fields = ["headline", "reporter"] class Query(ObjectType): @@ -451,6 +463,7 @@ def test_filter_filterset_related_results_with_filter(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" filter_fields = {"first_name": ["icontains"]} class Query(ObjectType): @@ -496,6 +509,7 @@ def test_recursive_filter_connection(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class Query(ObjectType): all_reporters = DjangoFilterConnectionField(ReporterFilterNode) @@ -521,11 +535,13 @@ def test_should_query_filter_node_limit(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class ArticleType(DjangoObjectType): class Meta: model = Article interfaces = (Node,) + fields = "__all__" filter_fields = ("lang",) class Query(ObjectType): @@ -610,6 +626,7 @@ def test_order_by_is_perserved(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" filter_fields = () class Query(ObjectType): @@ -676,6 +693,7 @@ def test_annotation_is_preserved(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" filter_fields = () class Query(ObjectType): @@ -718,6 +736,7 @@ def test_annotation_with_only(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" filter_fields = () class Query(ObjectType): @@ -758,6 +777,7 @@ def test_node_get_queryset_is_called(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" filter_fields = () @classmethod @@ -956,6 +976,7 @@ def test_filter_filterset_based_on_mixin(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class NewArticleFilterNode(DjangoObjectType): viewer = Field(NewReporterNode) @@ -963,6 +984,7 @@ def test_filter_filterset_based_on_mixin(): class Meta: model = Article interfaces = (Node,) + fields = "__all__" filterset_class = NewArticleFilter def resolve_viewer(self, info): diff --git a/graphene_django/rest_framework/tests/test_multiple_model_serializers.py b/graphene_django/rest_framework/tests/test_multiple_model_serializers.py index 1676b62..0332b3c 100644 --- a/graphene_django/rest_framework/tests/test_multiple_model_serializers.py +++ b/graphene_django/rest_framework/tests/test_multiple_model_serializers.py @@ -27,12 +27,14 @@ class ParentType(DjangoObjectType): class Meta: model = MyFakeParentModel interfaces = (graphene.relay.Node,) + fields = "__all__" class ChildType(DjangoObjectType): class Meta: model = MyFakeChildModel interfaces = (graphene.relay.Node,) + fields = "__all__" class MyModelChildSerializer(serializers.ModelSerializer): diff --git a/graphene_django/rest_framework/tests/test_mutation.py b/graphene_django/rest_framework/tests/test_mutation.py index 1b31e36..63285b2 100644 --- a/graphene_django/rest_framework/tests/test_mutation.py +++ b/graphene_django/rest_framework/tests/test_mutation.py @@ -165,6 +165,7 @@ def test_nested_model(): class MyFakeModelGrapheneType(DjangoObjectType): class Meta: model = MyFakeModel + fields = "__all__" class MyMutation(SerializerMutation): class Meta: diff --git a/graphene_django/tests/schema.py b/graphene_django/tests/schema.py index d0d9e47..757ef38 100644 --- a/graphene_django/tests/schema.py +++ b/graphene_django/tests/schema.py @@ -9,6 +9,7 @@ class Character(DjangoObjectType): class Meta: model = Reporter interfaces = (relay.Node,) + fields = "__all__" def get_node(self, info, id): pass @@ -20,6 +21,7 @@ class Human(DjangoObjectType): class Meta: model = Article interfaces = (relay.Node,) + fields = "__all__" def resolve_raises(self, info): raise Exception("This field should raise exception") diff --git a/graphene_django/tests/test_converter.py b/graphene_django/tests/test_converter.py index 7340fb4..d31d6f5 100644 --- a/graphene_django/tests/test_converter.py +++ b/graphene_django/tests/test_converter.py @@ -245,6 +245,7 @@ def test_should_manytomany_convert_connectionorlist_list(): class A(DjangoObjectType): class Meta: model = Reporter + fields = "__all__" graphene_field = convert_django_field( Reporter._meta.local_many_to_many[0], A._meta.registry @@ -265,6 +266,7 @@ def test_should_manytomany_convert_connectionorlist_connection(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" graphene_field = convert_django_field( Reporter._meta.local_many_to_many[0], A._meta.registry @@ -279,6 +281,7 @@ def test_should_manytoone_convert_connectionorlist(): class A(DjangoObjectType): class Meta: model = Article + fields = "__all__" graphene_field = convert_django_field(Reporter.articles.rel, A._meta.registry) assert isinstance(graphene_field, graphene.Dynamic) @@ -295,6 +298,7 @@ def test_should_onetoone_reverse_convert_model(): class A(DjangoObjectType): class Meta: model = FilmDetails + fields = "__all__" graphene_field = convert_django_field(Film.details.related, A._meta.registry) assert isinstance(graphene_field, graphene.Dynamic) diff --git a/graphene_django/tests/test_query.py b/graphene_django/tests/test_query.py index f7f7c4e..ad53230 100644 --- a/graphene_django/tests/test_query.py +++ b/graphene_django/tests/test_query.py @@ -89,6 +89,7 @@ def test_should_query_well(): class ReporterType(DjangoObjectType): class Meta: model = Reporter + fields = "__all__" class Query(graphene.ObjectType): reporter = graphene.Field(ReporterType) @@ -130,6 +131,7 @@ def test_should_query_postgres_fields(): class EventType(DjangoObjectType): class Meta: model = Event + fields = "__all__" class Query(graphene.ObjectType): event = graphene.Field(EventType) @@ -171,6 +173,7 @@ def test_should_node(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" @classmethod def get_node(cls, info, id): @@ -183,6 +186,7 @@ def test_should_node(): class Meta: model = Article interfaces = (Node,) + fields = "__all__" @classmethod def get_node(cls, info, id): @@ -253,11 +257,13 @@ def test_should_query_onetoone_fields(): class Meta: model = Film interfaces = (Node,) + fields = "__all__" class FilmDetailsNode(DjangoObjectType): class Meta: model = FilmDetails interfaces = (Node,) + fields = "__all__" class Query(graphene.ObjectType): film = graphene.Field(FilmNode) @@ -352,6 +358,7 @@ def test_should_keep_annotations(): class Meta: model = Article interfaces = (Node,) + fields = "__all__" filter_fields = ("lang",) class Query(graphene.ObjectType): @@ -405,11 +412,13 @@ def test_should_query_node_filtering(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class ArticleType(DjangoObjectType): class Meta: model = Article interfaces = (Node,) + fields = "__all__" filter_fields = ("lang",) class Query(graphene.ObjectType): @@ -483,6 +492,7 @@ def test_should_query_node_filtering_with_distinct_queryset(): class Meta: model = Film interfaces = (Node,) + fields = "__all__" filter_fields = ("genre",) class Query(graphene.ObjectType): @@ -527,11 +537,13 @@ def test_should_query_node_multiple_filtering(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class ArticleType(DjangoObjectType): class Meta: model = Article interfaces = (Node,) + fields = "__all__" filter_fields = ("lang", "headline") class Query(graphene.ObjectType): @@ -612,6 +624,7 @@ def test_should_enforce_first_or_last(graphene_settings): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class Query(graphene.ObjectType): all_reporters = DjangoConnectionField(ReporterType) @@ -651,6 +664,7 @@ def test_should_error_if_first_is_greater_than_max(graphene_settings): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class Query(graphene.ObjectType): all_reporters = DjangoConnectionField(ReporterType) @@ -692,6 +706,7 @@ def test_should_error_if_last_is_greater_than_max(graphene_settings): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class Query(graphene.ObjectType): all_reporters = DjangoConnectionField(ReporterType) @@ -733,6 +748,7 @@ def test_should_query_promise_connectionfields(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class Query(graphene.ObjectType): all_reporters = DjangoConnectionField(ReporterType) @@ -770,6 +786,7 @@ def test_should_query_connectionfields_with_last(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class Query(graphene.ObjectType): all_reporters = DjangoConnectionField(ReporterType) @@ -811,6 +828,7 @@ def test_should_query_connectionfields_with_manager(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" class Query(graphene.ObjectType): all_reporters = DjangoConnectionField(ReporterType, on="doe_objects") @@ -857,12 +875,14 @@ def test_should_query_dataloader_fields(): class Meta: model = Article interfaces = (Node,) + fields = "__all__" class ReporterType(DjangoObjectType): class Meta: model = Reporter interfaces = (Node,) use_connection = True + fields = "__all__" articles = DjangoConnectionField(ArticleType) @@ -947,10 +967,12 @@ def test_should_handle_inherited_choices(): class BaseType(DjangoObjectType): class Meta: model = BaseModel + fields = "__all__" class ChildType(DjangoObjectType): class Meta: model = ChildModel + fields = "__all__" class Query(graphene.ObjectType): base = graphene.Field(BaseType) @@ -978,12 +1000,14 @@ def test_proxy_model_support(): model = Reporter interfaces = (Node,) use_connection = True + fields = "__all__" class CNNReporterType(DjangoObjectType): class Meta: model = CNNReporter interfaces = (Node,) use_connection = True + fields = "__all__" reporter = Reporter.objects.create( first_name="John", last_name="Doe", email="johndoe@example.com", a_choice=1 @@ -1056,6 +1080,7 @@ def test_should_resolve_get_queryset_connectionfields(): class Meta: model = Reporter interfaces = (Node,) + fields = "__all__" @classmethod def get_queryset(cls, queryset, info): @@ -1089,6 +1114,7 @@ def test_should_preserve_prefetch_related(django_assert_num_queries): class Meta: model = Reporter interfaces = (graphene.relay.Node,) + fields = "__all__" class FilmType(DjangoObjectType): reporters = DjangoConnectionField(ReporterType) @@ -1096,6 +1122,7 @@ def test_should_preserve_prefetch_related(django_assert_num_queries): class Meta: model = Film interfaces = (graphene.relay.Node,) + fields = "__all__" class Query(graphene.ObjectType): films = DjangoConnectionField(FilmType) @@ -1141,6 +1168,7 @@ def test_should_preserve_annotations(): class Meta: model = Reporter interfaces = (graphene.relay.Node,) + fields = "__all__" class FilmType(DjangoObjectType): reporters = DjangoConnectionField(ReporterType) @@ -1149,6 +1177,7 @@ def test_should_preserve_annotations(): class Meta: model = Film interfaces = (graphene.relay.Node,) + fields = "__all__" class Query(graphene.ObjectType): films = DjangoConnectionField(FilmType) diff --git a/graphene_django/tests/test_schema.py b/graphene_django/tests/test_schema.py index 2c2f74b..1c889f1 100644 --- a/graphene_django/tests/test_schema.py +++ b/graphene_django/tests/test_schema.py @@ -9,7 +9,7 @@ def test_should_raise_if_no_model(): with raises(Exception) as excinfo: class Character1(DjangoObjectType): - pass + fields = "__all__" assert "valid Django Model" in str(excinfo.value) @@ -20,6 +20,7 @@ def test_should_raise_if_model_is_invalid(): class Character2(DjangoObjectType): class Meta: model = 1 + fields = "__all__" assert "valid Django Model" in str(excinfo.value) @@ -29,6 +30,7 @@ def test_should_map_fields_correctly(): class Meta: model = Reporter registry = Registry() + fields = "__all__" fields = list(ReporterType2._meta.fields.keys()) assert fields[:-2] == [ diff --git a/graphene_django/tests/test_types.py b/graphene_django/tests/test_types.py index 9811d48..8f8126f 100644 --- a/graphene_django/tests/test_types.py +++ b/graphene_django/tests/test_types.py @@ -19,6 +19,7 @@ class Reporter(DjangoObjectType): class Meta: model = ReporterModel + fields = "__all__" class ArticleConnection(Connection): @@ -40,6 +41,7 @@ class Article(DjangoObjectType): model = ArticleModel interfaces = (Node,) connection_class = ArticleConnection + fields = "__all__" class RootQuery(ObjectType): @@ -106,6 +108,7 @@ def test_django_objecttype_with_custom_meta(): class Article(ArticleType): class Meta: model = ArticleModel + fields = "__all__" assert isinstance(Article._meta, ArticleTypeOptions) @@ -531,6 +534,7 @@ class TestDjangoObjectType: class Meta: model = PetModel convert_choices_to_enum = False + fields = "__all__" class Query(ObjectType): pet = Field(Pet) @@ -561,6 +565,7 @@ class TestDjangoObjectType: class Meta: model = PetModel convert_choices_to_enum = ["kind"] + fields = "__all__" class Query(ObjectType): pet = Field(Pet) @@ -600,6 +605,7 @@ class TestDjangoObjectType: class Meta: model = PetModel convert_choices_to_enum = [] + fields = "__all__" class Query(ObjectType): pet = Field(Pet)