File: test_concat_ast.py

package info (click to toggle)
graphql-core 3.2.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,384 kB
  • sloc: python: 45,812; makefile: 26; sh: 13
file content (39 lines) | stat: -rw-r--r-- 769 bytes parent folder | download | duplicates (2)
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
38
39
from graphql.language import parse, print_ast, Source
from graphql.utilities import concat_ast

from ..utils import dedent


def describe_concat_ast():
    def concatenates_two_asts_together():
        source_a = Source(
            """
            { a, b, ... Frag }
            """
        )

        source_b = Source(
            """
            fragment Frag on T {
                c
            }
            """
        )

        ast_a = parse(source_a)
        ast_b = parse(source_b)
        ast_c = concat_ast([ast_a, ast_b])

        assert print_ast(ast_c) == dedent(
            """
            {
              a
              b
              ...Frag
            }

            fragment Frag on T {
              c
            }
            """
        )