File: test_star_wars_mutations.py

package info (click to toggle)
graphql-relay 3.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 416 kB
  • sloc: python: 3,006; sh: 14; makefile: 4
file content (37 lines) | stat: -rw-r--r-- 1,057 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from graphql import graphql_sync

from .star_wars_schema import star_wars_schema as schema


def describe_star_wars_mutations():
    def correctly_mutates_dataset():
        source = """
          mutation ($input: IntroduceShipInput!) {
            introduceShip(input: $input) {
              ship {
                id
                name
              }
              faction {
                name
              }
              clientMutationId
            }
          }
        """
        variable_values = {
            "input": {
                "shipName": "B-Wing",
                "factionId": "1",
                "clientMutationId": "abcde",
            }
        }
        expected = {
            "introduceShip": {
                "ship": {"id": "U2hpcDo5", "name": "B-Wing"},
                "faction": {"name": "Alliance to Restore the Republic"},
                "clientMutationId": "abcde",
            }
        }
        result = graphql_sync(schema, source, variable_values=variable_values)
        assert result == (expected, None)