diff --git a/tests/benchmarks/api.py b/tests/benchmarks/api.py index 24b3d3c888..f4a7ea4bb9 100644 --- a/tests/benchmarks/api.py +++ b/tests/benchmarks/api.py @@ -1,7 +1,7 @@ from collections.abc import AsyncIterator import strawberry -from strawberry.directive import DirectiveLocation +from strawberry.directive import DirectiveLocation, DirectiveValue @strawberry.type @@ -80,7 +80,7 @@ async def long_running(self, count: int) -> AsyncIterator[int]: @strawberry.directive(locations=[DirectiveLocation.FIELD]) -def uppercase(value: str) -> str: +def uppercase(value: DirectiveValue[str]) -> str: return value.upper() diff --git a/tests/federation/printer/test_additional_directives.py b/tests/federation/printer/test_additional_directives.py index 5fedbb734e..58aff77180 100644 --- a/tests/federation/printer/test_additional_directives.py +++ b/tests/federation/printer/test_additional_directives.py @@ -30,11 +30,21 @@ class Query: } type Query { + _entities(representations: [_Any!]!): [_Entity]! + _service: _Service! federatedType: FederatedType! } + + scalar _Any + + union _Entity = FederatedType + + type _Service { + sdl: String! + } """ - schema = strawberry.Schema( + schema = strawberry.federation.Schema( query=Query, config=StrawberryConfig(auto_camel_case=False) ) assert schema.as_str() == textwrap.dedent(expected_type).strip() @@ -72,11 +82,21 @@ class Query: } type Query { + _entities(representations: [_Any!]!): [_Entity]! + _service: _Service! federatedType: FederatedType! } + + scalar _Any + + union _Entity = FederatedType + + type _Service { + sdl: String! + } """ - schema = strawberry.Schema( + schema = strawberry.federation.Schema( query=Query, config=StrawberryConfig(auto_camel_case=False) ) assert schema.as_str() == textwrap.dedent(expected_type).strip() diff --git a/tests/federation/printer/test_inaccessible.py b/tests/federation/printer/test_inaccessible.py index 110ec1075d..01fc8d9eda 100644 --- a/tests/federation/printer/test_inaccessible.py +++ b/tests/federation/printer/test_inaccessible.py @@ -1,6 +1,6 @@ import textwrap from enum import Enum -from typing import Annotated +from typing import Annotated, Union import strawberry @@ -249,11 +249,13 @@ class A: class B: b: str - Union = strawberry.federation.union("Union", (A, B), inaccessible=True) + MyUnion = Annotated[ + Union[A, B], strawberry.federation.union("Union", inaccessible=True) + ] @strawberry.federation.type class Query: - hello: Union + hello: MyUnion schema = strawberry.federation.Schema(query=Query, enable_federation_2=True) diff --git a/tests/federation/printer/test_tag.py b/tests/federation/printer/test_tag.py index f485f16524..69e87fb342 100644 --- a/tests/federation/printer/test_tag.py +++ b/tests/federation/printer/test_tag.py @@ -1,6 +1,6 @@ import textwrap from enum import Enum -from typing import Annotated +from typing import Annotated, Union import strawberry @@ -167,11 +167,13 @@ class A: class B: b: str - Union = strawberry.federation.union("Union", (A, B), tags=["myTag", "anotherTag"]) + MyUnion = Annotated[ + Union[A, B], strawberry.federation.union("Union", tags=["myTag", "anotherTag"]) + ] @strawberry.federation.type class Query: - hello: Union + hello: MyUnion schema = strawberry.federation.Schema(query=Query, enable_federation_2=True) diff --git a/tests/schema/test_resolvers.py b/tests/schema/test_resolvers.py index 4f0758f72f..0bcf6f41d5 100644 --- a/tests/schema/test_resolvers.py +++ b/tests/schema/test_resolvers.py @@ -614,20 +614,6 @@ def multiple_infos(root, info1: Info, info2: Info) -> str: pytest.param(parent_self_and_root), pytest.param(multiple_parents), pytest.param(multiple_infos), - pytest.param( - parent_and_self, - marks=pytest.mark.xfail( - strict=True, - reason="`self` should not raise ConflictingArgumentsError", - ), - ), - pytest.param( - self_and_root, - marks=pytest.mark.xfail( - strict=True, - reason="`self` should not raise ConflictingArgumentsError", - ), - ), ), ) @pytest.mark.raises_strawberry_exception( @@ -643,3 +629,12 @@ class Query: name: str = strawberry.field(resolver=resolver) strawberry.Schema(query=Query) + + +@pytest.mark.parametrize("resolver", (parent_and_self, self_and_root)) +def test_self_should_not_raise_conflicting_arguments_error(resolver): + @strawberry.type + class Query: + name: str = strawberry.field(resolver=resolver) + + strawberry.Schema(query=Query) diff --git a/tests/test_deprecations.py b/tests/test_deprecations.py index 33e81b949f..1d9ac3abf8 100644 --- a/tests/test_deprecations.py +++ b/tests/test_deprecations.py @@ -10,7 +10,10 @@ class A: def test_type_definition_is_aliased(): - assert A.__strawberry_definition__ is A._type_definition + with pytest.warns( + match="_type_definition is deprecated, use __strawberry_definition__ instead" + ): + assert A.__strawberry_definition__ is A._type_definition def test_get_warns():