Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warnings caused by tests #3727

Prev Previous commit
Test directives still work as expected
DoctorJohn committed Dec 15, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 4be9c5b601e1cb4dcafe4134ce3ddb9fa15c4839
25 changes: 22 additions & 3 deletions tests/schema/test_directives.py
Original file line number Diff line number Diff line change
@@ -103,7 +103,9 @@
def test_can_declare_directives():
@strawberry.type
class Query:
cake: str = "made_in_switzerland"
@strawberry.field
def cake(self) -> str:
return "made_in_switzerland"

@strawberry.directive(
locations=[DirectiveLocation.FIELD], description="Make string uppercase"
@@ -124,6 +126,10 @@

assert schema.as_str() == textwrap.dedent(expected_schema).strip()

result = schema.execute_sync('query { cake @uppercase(example: "foo") }')
assert result.errors is None
assert result.data == {"cake": "MADE_IN_SWITZERLAND"}


def test_directive_arguments_without_value_param():
"""Regression test for Strawberry Issue #1666.
@@ -199,6 +205,7 @@
result = schema.execute_sync(query, variable_values={"identified": False})

assert not result.errors
assert result.data
assert result.data["person"]["name"] == "JESS"
assert result.data["jess"]["name"] == "Jessica"
assert result.data["johnDoe"].get("name") is None
@@ -315,7 +322,7 @@
result = schema.execute_sync(query, variable_values={"identified": False})

assert not result.errors
assert result.data

Check warning on line 325 in tests/schema/test_directives.py

Codecov / codecov/patch

tests/schema/test_directives.py#L325

Added line #L325 was not covered by tests
assert result.data["person"]["name"] == "JESS"


@@ -609,7 +616,9 @@

@strawberry.type
class Query:
cake: str = "made_in_switzerland"
@strawberry.field
def cake(self) -> str:
return "made_in_switzerland"

@strawberry.directive(
locations=[DirectiveLocation.FIELD], description="Make string uppercase"
@@ -634,13 +643,19 @@

assert schema.as_str() == textwrap.dedent(expected_schema).strip()

result = schema.execute_sync('query { cake @uppercase(input: { example: "foo" }) }')
assert result.errors is None
assert result.data == {"cake": "MADE_IN_SWITZERLAND"}


def test_directives_with_scalar():
DirectiveInput = strawberry.scalar(str, name="DirectiveInput")

@strawberry.type
class Query:
cake: str = "made_in_switzerland"
@strawberry.field
def cake(self) -> str:
return "made_in_switzerland"

@strawberry.directive(
locations=[DirectiveLocation.FIELD], description="Make string uppercase"
@@ -663,6 +678,10 @@

assert schema.as_str() == textwrap.dedent(expected_schema).strip()

result = schema.execute_sync('query { cake @uppercase(input: "foo") }')
assert result.errors is None
assert result.data == {"cake": "MADE_IN_SWITZERLAND"}


@pytest.mark.asyncio
async def test_directive_with_custom_info_class() -> NoReturn: