graphene icon indicating copy to clipboard operation
graphene copied to clipboard

Make tests work with GraphQL-core 3.2.0rc2

Open Cito opened this issue 4 years ago • 5 comments

This fix aligns to some changes in GraphQL-core 3.2 which reflect changes in GraphQL.js 16:

  • type resolvers must return only names
  • doesn't print trailing newlines any more
  • different wording of some error messages

Cito avatar Sep 30 '21 08:09 Cito

Closes #1406 ? Our CI caught another faulty import with 3.2 btw: https://github.com/graphql-python/graphene/pull/1415/files

ddelange avatar Apr 04 '22 15:04 ddelange

In addition to the remaining issue already referenced we see

_________________________ test_node_query_incorrect_id _________________________

    def test_node_query_incorrect_id():
        executed = schema.execute(
            '{ node(id:"%s") { ... on MyNode { name } } }' % "something:2"
        )
        assert executed.errors
>       assert re.match(r"Unable to parse global ID .*", executed.errors[0].message)
E       assert None
E        +  where None = <function match at 0x7ffff75181f0>('Unable to parse global ID .*', 'Relay Node "" not found in schema')
E        +    where <function match at 0x7ffff75181f0> = re.match
E        +    and   'Relay Node "" not found in schema' = GraphQLError('Relay Node "" not found in schema', locations=[SourceLocation(line=1, column=3)], path=['node']).message

graphene/relay/tests/test_node.py:109: AssertionError
___________________________ test_example_end_to_end ____________________________

    def test_example_end_to_end():
        class Movie(graphene.ObjectType):
            class Meta:
                interfaces = (relay.Node,)
                default_resolver = dict_resolver

            name = graphene.String(required=True)
            synopsis = graphene.String(required=True)

        class Event(graphene.ObjectType):
            class Meta:
                interfaces = (relay.Node,)
                default_resolver = dict_resolver

            movie = graphene.Field(Movie, required=True)
            date = graphene.types.datetime.Date(required=True)

            def resolve_movie(event, info):
                return TEST_DATA["movies"][event["movie"]]

        class Query(graphene.ObjectType):
            events = graphene.List(graphene.NonNull(Event), required=True)

            def resolve_events(_, info):
                return TEST_DATA["events"]

        schema = graphene.Schema(query=Query)
        query = """\
            {
                events {
                    __typename
                    id
                    date
                    movie {
                        __typename
                        id
                        name
                        synopsis
                    }
                }
            }
        """
        result = schema.execute(query)
>       assert not result.errors
E       AssertionError: assert not [GraphQLError('ID cannot represent value: None', locations=[SourceLocation(line=8, column=21)], path=['events', 0, 'movie', 'id'])]
E        +  where [GraphQLError('ID cannot represent value: None', locations=[SourceLocation(line=8, column=21)], path=['events', 0, 'movie', 'id'])] = ExecutionResult(data=None, errors=[GraphQLError('ID cannot represent value: None', locations=[SourceLocation(line=8, column=21)], path=['events', 0, 'movie', 'id'])]).errors

graphene/utils/tests/test_deduplicator.py:151: AssertionError

mweinelt avatar Apr 16 '22 11:04 mweinelt

I made a pull request built on top of this pull request, hopefully fixing the remaining issues: https://github.com/graphql-python/graphene/pull/1417

JonathanWylie avatar Apr 19 '22 06:04 JonathanWylie

This can be closed with the 3.1.0 release.

SuperSandro2000 avatar Jun 01 '22 20:06 SuperSandro2000

yes, superceded by https://github.com/graphql-python/graphene/pull/1421

ddelange avatar Jun 02 '22 04:06 ddelange

@ddelange @SuperSandro2000 thank you for linking the other issue!

erikwrede avatar Aug 13 '22 12:08 erikwrede