Skip to content

Commit

Permalink
✅ Fix test with newer graphene
Browse files Browse the repository at this point in the history
null default values
no more trailing newlines
  • Loading branch information
nikolaik committed Aug 15, 2022
1 parent f94d254 commit dc87546
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,7 @@ def test_array_field_filter_schema_type(Query):
"randomField": "[Boolean!]",
}
filters_str = ", ".join(
[
f"{filter_field}: {gql_type} = null"
for filter_field, gql_type in filters.items()
]
[f"{filter_field}: {gql_type}" for filter_field, gql_type in filters.items()]
)
assert (
f"type Query {{\n events({filters_str}): EventTypeConnection\n}}" in schema_str
Expand Down
5 changes: 1 addition & 4 deletions graphene_django/filter/tests/test_enum_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ def test_filter_enum_field_schema_type(schema):
"reporter_AChoice_In": "[TestsReporterAChoiceChoices]",
}
filters_str = ", ".join(
[
f"{filter_field}: {gql_type} = null"
for filter_field, gql_type in filters.items()
]
[f"{filter_field}: {gql_type}" for filter_field, gql_type in filters.items()]
)
assert f" allArticles({filters_str}): ArticleTypeConnection\n" in schema_str
10 changes: 4 additions & 6 deletions graphene_django/filter/tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ class Query(ObjectType):
assert str(schema) == dedent(
"""\
type Query {
pets(offset: Int = null, before: String = null, after: String = null, first: Int = null, last: Int = null, age: Int = null): PetTypeConnection
pets(offset: Int, before: String, after: String, first: Int, last: Int, age: Int): PetTypeConnection
}
type PetTypeConnection {
Expand Down Expand Up @@ -1056,8 +1056,7 @@ class Query(ObjectType):
interface Node {
\"""The ID of the object\"""
id: ID!
}
"""
}"""
)


Expand All @@ -1077,7 +1076,7 @@ class Query(ObjectType):
assert str(schema) == dedent(
"""\
type Query {
pets(offset: Int = null, before: String = null, after: String = null, first: Int = null, last: Int = null, age: Int = null, age_Isnull: Boolean = null, age_Lt: Int = null): PetTypeConnection
pets(offset: Int, before: String, after: String, first: Int, last: Int, age: Int, age_Isnull: Boolean, age_Lt: Int): PetTypeConnection
}
type PetTypeConnection {
Expand Down Expand Up @@ -1125,8 +1124,7 @@ class Query(ObjectType):
interface Node {
\"""The ID of the object\"""
id: ID!
}
"""
}"""
)


Expand Down
2 changes: 1 addition & 1 deletion graphene_django/filter/tests/test_typed_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_typed_filter_schema(schema):
)

for filter_field, gql_type in filters.items():
assert "{}: {} = null".format(filter_field, gql_type) in all_articles_filters
assert "{}: {}".format(filter_field, gql_type) in all_articles_filters


def test_typed_filters_work(schema):
Expand Down
3 changes: 1 addition & 2 deletions graphene_django/tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,5 @@ class Query(ObjectType):
"""\
type Query {
hi: String
}
"""
}"""
)
20 changes: 7 additions & 13 deletions graphene_django/tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def test_schema_representation():
pets: [Reporter!]!
aChoice: TestsReporterAChoiceChoices
reporterType: TestsReporterReporterTypeChoices
articles(offset: Int = null, before: String = null, after: String = null, first: Int = null, last: Int = null): ArticleConnection!
articles(offset: Int, before: String, after: String, first: Int, last: Int): ArticleConnection!
}
\"""An enumeration.\"""
Expand Down Expand Up @@ -244,8 +244,7 @@ def test_schema_representation():
\"""The ID of the object\"""
id: ID!
): Node
}
"""
}"""
)
assert str(schema) == expected

Expand Down Expand Up @@ -525,8 +524,7 @@ class Query(ObjectType):
id: ID!
kind: String!
cuteness: Int!
}
"""
}"""
)

def test_django_objecttype_convert_choices_enum_list(self, PetModel):
Expand Down Expand Up @@ -560,8 +558,7 @@ class Query(ObjectType):
\"""Dog\"""
DOG
}
"""
}"""
)

def test_django_objecttype_convert_choices_enum_empty_list(self, PetModel):
Expand All @@ -586,8 +583,7 @@ class Query(ObjectType):
id: ID!
kind: String!
cuteness: Int!
}
"""
}"""
)

def test_django_objecttype_convert_choices_enum_naming_collisions(
Expand Down Expand Up @@ -621,8 +617,7 @@ class Query(ObjectType):
\"""Dog\"""
DOG
}
"""
}"""
)

def test_django_objecttype_choices_custom_enum_name(
Expand Down Expand Up @@ -660,8 +655,7 @@ class Query(ObjectType):
\"""Dog\"""
DOG
}
"""
}"""
)


Expand Down
5 changes: 0 additions & 5 deletions graphene_django/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,10 @@ def test_reports_validation_errors(client):
{
"message": "Cannot query field 'unknownOne' on type 'QueryRoot'.",
"locations": [{"line": 1, "column": 9}],
"path": None,
},
{
"message": "Cannot query field 'unknownTwo' on type 'QueryRoot'.",
"locations": [{"line": 1, "column": 21}],
"path": None,
},
]
}
Expand All @@ -135,8 +133,6 @@ def test_errors_when_missing_operation_name(client):
"errors": [
{
"message": "Must provide operation name if query contains multiple operations.",
"locations": None,
"path": None,
}
]
}
Expand Down Expand Up @@ -477,7 +473,6 @@ def test_handles_syntax_errors_caught_by_graphql(client):
{
"locations": [{"column": 1, "line": 1}],
"message": "Syntax Error: Unexpected Name 'syntaxerror'.",
"path": None,
}
]
}
Expand Down

0 comments on commit dc87546

Please sign in to comment.