Skip to content

Commit

Permalink
Adapt error message in test to change in wording
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed May 16, 2020
1 parent a667915 commit e76c576
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
35 changes: 16 additions & 19 deletions tests/starwars/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_hero_name_query(client):
name
}
}
"""
"""
)
expected = {"hero": {"name": "R2-D2"}}
result = client.execute(query)
Expand All @@ -37,7 +37,7 @@ def test_hero_name_and_friends_query(client):
}
}
}
"""
"""
)
expected = {
"hero": {
Expand Down Expand Up @@ -69,7 +69,7 @@ def test_nested_query(client):
}
}
}
"""
"""
)
expected = {
"hero": {
Expand Down Expand Up @@ -119,7 +119,7 @@ def test_fetch_luke_query(client):
name
}
}
"""
"""
)
expected = {"human": {"name": "Luke Skywalker"}}
result = client.execute(query)
Expand All @@ -134,7 +134,7 @@ def test_fetch_some_id_query(client):
name
}
}
"""
"""
)
params = {
"someId": "1000",
Expand All @@ -152,7 +152,7 @@ def test_fetch_some_id_query2(client):
name
}
}
"""
"""
)
params = {
"someId": "1002",
Expand All @@ -170,7 +170,7 @@ def test_invalid_id_query(client):
name
}
}
"""
"""
)
params = {
"id": "not a valid id",
Expand All @@ -188,7 +188,7 @@ def test_fetch_luke_aliased(client):
name
}
}
"""
"""
)
expected = {"luke": {"name": "Luke Skywalker"}}
result = client.execute(query)
Expand All @@ -206,7 +206,7 @@ def test_fetch_luke_and_leia_aliased(client):
name
}
}
"""
"""
)
expected = {"luke": {"name": "Luke Skywalker"}, "leia": {"name": "Leia Organa"}}
result = client.execute(query)
Expand All @@ -226,7 +226,7 @@ def test_duplicate_fields(client):
homePlanet
}
}
"""
"""
)
expected = {
"luke": {"name": "Luke Skywalker", "homePlanet": "Tatooine"},
Expand All @@ -251,7 +251,7 @@ def test_use_fragment(client):
name
homePlanet
}
"""
"""
)
expected = {
"luke": {"name": "Luke Skywalker", "homePlanet": "Tatooine"},
Expand All @@ -270,7 +270,7 @@ def test_check_type_of_r2(client):
name
}
}
"""
"""
)
expected = {"hero": {"__typename": "Droid", "name": "R2-D2"}}
result = client.execute(query)
Expand All @@ -286,30 +286,27 @@ def test_check_type_of_luke(client):
name
}
}
"""
"""
)
expected = {"hero": {"__typename": "Human", "name": "Luke Skywalker"}}
result = client.execute(query)
assert result == expected


def test_parse_error(client):
result = None
with pytest.raises(Exception) as exc_info:
query = gql(
gql(
"""
qeury
"""
"""
)
result = client.execute(query)
error = exc_info.value
formatted_error = format_error(error)
assert formatted_error["locations"] == [{"column": 13, "line": 2}]
assert (
'Syntax Error GraphQL request (2:13) Unexpected Name "qeury"'
in formatted_error["message"]
)
assert not result


def test_mutation_result(client):
Expand All @@ -321,7 +318,7 @@ def test_mutation_result(client):
commentary
}
}
"""
"""
)
params = {
"ep": "JEDI",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_no_schema_exception():
with pytest.raises(Exception) as exc_info:
client = Client()
client.validate("")
assert "Cannot validate locally the document, you need to pass a schema." in str(
assert "Cannot validate the document locally, you need to pass a schema." in str(
exc_info.value
)

Expand Down

0 comments on commit e76c576

Please sign in to comment.