Skip to content

Commit

Permalink
Fix tests with graphql-core 3.1.5 (#211)
Browse files Browse the repository at this point in the history
* Fix tests to allow graphql-core>=3.1.5 to break arguments over multiple lines
* Stop checking exact error message when passing an int to gql
  • Loading branch information
leszekhanusz authored May 22, 2021
1 parent 73d0ba5 commit beab41b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
30 changes: 28 additions & 2 deletions tests/starwars/test_dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,15 @@ def test_multiple_operations(ds):
),
)

"""
From graphql-core version 3.1.5, print_ast() break arguments over multiple lines
Accepting both cases here
"""

assert (
print_ast(query)
== """query GetHeroName {
(
print_ast(query)
== """query GetHeroName {
hero {
name
}
Expand All @@ -280,6 +286,26 @@ def test_multiple_operations(ds):
}
}
"""
)
or (
print_ast(query)
== """query GetHeroName {
hero {
name
}
}
mutation CreateReviewMutation {
createReview(
episode: JEDI
review: {stars: 5, commentary: "This is a great movie!"}
) {
stars
commentary
}
}
"""
)
)


Expand Down
18 changes: 16 additions & 2 deletions tests/starwars/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,23 @@ def validation_errors(client, query):


def test_incompatible_request_gql(client):
with pytest.raises(TypeError) as exc_info:
with pytest.raises(TypeError):
gql(123)
assert "body must be a string" in str(exc_info.value)

"""
The error generated depends on graphql-core version
< 3.1.5: "body must be a string"
>= 3.1.5: some variation of "object of type 'int' has no len()"
depending on the python environment
So we are not going to check the exact error message here anymore.
"""

"""
assert ("body must be a string" in str(exc_info.value)) or (
"object of type 'int' has no len()" in str(exc_info.value)
)
"""


def test_nested_query_with_fragment(client):
Expand Down

0 comments on commit beab41b

Please sign in to comment.