Skip to content

Commit

Permalink
Adjust tests depending on previous behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorJohn committed Nov 14, 2023
1 parent 0c3bb2a commit 243565e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
11 changes: 7 additions & 4 deletions tests/schema/test_execution_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ async def name(self) -> str:
}
"""

with pytest.raises(RuntimeError) as e:
schema.execute_sync(query)

assert e.value.args[0] == "GraphQL execution failed to complete synchronously."
result = schema.execute_sync(query)
assert len(result.errors) == 1
assert isinstance(result.errors[0].original_error, RuntimeError)
assert (
result.errors[0].message
== "GraphQL execution failed to complete synchronously."
)


@pytest.mark.asyncio
Expand Down
13 changes: 8 additions & 5 deletions tests/types/test_execution.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest

import strawberry
from strawberry.extensions import SchemaExtension
Expand Down Expand Up @@ -150,8 +149,10 @@ def on_operation(self):

schema = strawberry.Schema(Query, extensions=[MyExtension])

with pytest.raises(RuntimeError):
schema.execute_sync("mutation { myMutation }")
result = schema.execute_sync("mutation { myMutation }")
assert len(result.errors) == 1
assert isinstance(result.errors[0].original_error, RuntimeError)
assert result.errors[0].message == "No GraphQL document available"


def test_error_when_accessing_operation_type_with_invalid_operation_name():
Expand All @@ -165,5 +166,7 @@ def on_parse(self):

schema = strawberry.Schema(Query, extensions=[MyExtension])

with pytest.raises(RuntimeError):
schema.execute_sync("query { ping }", operation_name="MyQuery")
result = schema.execute_sync("query { ping }", operation_name="MyQuery")
assert len(result.errors) == 1
assert isinstance(result.errors[0].original_error, RuntimeError)
assert result.errors[0].message == "Can't get GraphQL operation type"

0 comments on commit 243565e

Please sign in to comment.