|
5 | 5 | def error(frag_name, parent_type, frag_type, line, column):
|
6 | 6 | return {
|
7 | 7 | 'message': PossibleFragmentSpreads.type_incompatible_spread_message(frag_name, parent_type, frag_type),
|
8 |
| - 'locations': [{ 'line': line, 'column': column}] |
| 8 | + 'locations': [SourceLocation(line, column)] |
9 | 9 | }
|
10 | 10 |
|
11 | 11 |
|
12 |
| -def error_annon(frag_name, parent_type, frag_type, line, column): |
| 12 | +def error_anon(parent_type, frag_type, line, column): |
13 | 13 | return {
|
14 |
| - 'message': PossibleFragmentSpreads.type_incompatible_anon_spread_message(frag_name, parent_type, frag_type), |
15 |
| - 'locations': [{ 'line': line, 'column': column}] |
| 14 | + 'message': PossibleFragmentSpreads.type_incompatible_anon_spread_message(parent_type, frag_type), |
| 15 | + 'locations': [SourceLocation(line, column)] |
16 | 16 | }
|
17 | 17 |
|
18 |
| -def same_object(): |
| 18 | +def test_same_object(): |
19 | 19 | expect_passes_rule(PossibleFragmentSpreads, '''
|
20 | 20 | fragment objectWithinObject on Dog { ...dogFragment }
|
21 | 21 | fragment dogFragment on Dog { barkVolume }
|
22 | 22 | ''')
|
23 | 23 |
|
24 |
| -def same_object_inline_frag(): |
| 24 | +def test_same_object_inline_frag(): |
25 | 25 | expect_passes_rule(PossibleFragmentSpreads, '''
|
26 | 26 | fragment objectWithinObjectAnon on Dog { ... on Dog { barkVolume } }
|
27 | 27 | ''')
|
28 | 28 |
|
29 |
| -def object_into_implemented_interface(): |
| 29 | +def test_object_into_implemented_interface(): |
30 | 30 | expect_passes_rule(PossibleFragmentSpreads, '''
|
31 | 31 | fragment objectWithinInterface on Pet { ...dogFragment }
|
32 | 32 | fragment dogFragment on Dog { barkVolume }
|
33 | 33 | ''')
|
34 | 34 |
|
35 |
| -def object_into_containing_union(): |
| 35 | +def test_object_into_containing_union(): |
36 | 36 | expect_passes_rule(PossibleFragmentSpreads, '''
|
37 | 37 | fragment objectWithinUnion on CatOrDog { ...dogFragment }
|
38 | 38 | fragment dogFragment on Dog { barkVolume }
|
39 | 39 | ''')
|
40 | 40 |
|
41 |
| -def union_into_contained_object(): |
| 41 | +def test_union_into_contained_object(): |
42 | 42 | expect_passes_rule(PossibleFragmentSpreads, '''
|
43 | 43 | fragment unionWithinObject on Dog { ...catOrDogFragment }
|
44 | 44 | fragment catOrDogFragment on CatOrDog { __typename }
|
45 | 45 | ''')
|
46 | 46 |
|
47 |
| -def union_into_overlapping_interface(): |
| 47 | +def test_union_into_overlapping_interface(): |
48 | 48 | expect_passes_rule(PossibleFragmentSpreads, '''
|
49 | 49 | fragment unionWithinInterface on Pet { ...catOrDogFragment }
|
50 | 50 | fragment catOrDogFragment on CatOrDog { __typename }
|
51 | 51 | ''')
|
52 | 52 |
|
53 |
| -def union_into_overlapping_union(): |
| 53 | +def test_union_into_overlapping_union(): |
54 | 54 | expect_passes_rule(PossibleFragmentSpreads, '''
|
55 | 55 | fragment unionWithinUnion on DogOrHuman { ...catOrDogFragment }
|
56 | 56 | fragment catOrDogFragment on CatOrDog { __typename }
|
57 | 57 | ''')
|
58 | 58 |
|
59 |
| -def interface_into_implemented_object(): |
| 59 | +def test_interface_into_implemented_object(): |
60 | 60 | expect_passes_rule(PossibleFragmentSpreads, '''
|
61 | 61 | fragment interfaceWithinObject on Dog { ...petFragment }
|
62 | 62 | fragment petFragment on Pet { name }
|
63 | 63 | ''')
|
64 | 64 |
|
65 |
| -def interface_into_overlapping_interface(): |
| 65 | +def test_interface_into_overlapping_interface(): |
66 | 66 | expect_passes_rule(PossibleFragmentSpreads, '''
|
67 | 67 | fragment interfaceWithinInterface on Pet { ...beingFragment }
|
68 | 68 | fragment beingFragment on Being { name }
|
69 | 69 | ''')
|
70 | 70 |
|
71 |
| -def interface_into_overlapping_interface_in_inline_fragment(): |
| 71 | +def test_interface_into_overlapping_interface_in_inline_fragment(): |
72 | 72 | expect_passes_rule(PossibleFragmentSpreads, '''
|
73 | 73 | fragment interfaceWithinInterface on Pet { ... on Being { name } }
|
74 | 74 | ''')
|
75 | 75 |
|
76 |
| -def interface_into_overlapping_union(): |
| 76 | +def test_interface_into_overlapping_union(): |
77 | 77 | expect_passes_rule(PossibleFragmentSpreads, '''
|
78 | 78 | fragment interfaceWithinUnion on CatOrDog { ...petFragment }
|
79 | 79 | fragment petFragment on Pet { name }
|
80 | 80 | ''')
|
81 | 81 |
|
82 |
| -def different_object_into_object(): |
| 82 | +def test_different_object_into_object(): |
83 | 83 | expect_fails_rule(PossibleFragmentSpreads, '''
|
84 | 84 | fragment invalidObjectWithinObject on Cat { ...dogFragment }
|
85 | 85 | fragment dogFragment on Dog { barkVolume }
|
86 | 86 | ''', [error('dogFragment', 'Cat', 'Dog', 2, 51)])
|
87 | 87 |
|
88 |
| -def different_object_into_object_in_inline_fragment(): |
| 88 | +def test_different_object_into_object_in_inline_fragment(): |
89 | 89 | expect_fails_rule(PossibleFragmentSpreads, '''
|
90 | 90 | fragment invalidObjectWithinObjectAnon on Cat {
|
91 | 91 | ... on Dog { barkVolume }
|
92 | 92 | }
|
93 | 93 | ''', [error_anon('Cat', 'Dog', 3, 9)])
|
94 | 94 |
|
95 |
| -def object_into_not_implementing_interface(): |
| 95 | +def test_object_into_not_implementing_interface(): |
96 | 96 | expect_fails_rule(PossibleFragmentSpreads, '''
|
97 | 97 | fragment invalidObjectWithinInterface on Pet { ...humanFragment }
|
98 | 98 | fragment humanFragment on Human { pets { name } }
|
99 | 99 | ''', [error('humanFragment', 'Pet', 'Human', 2, 54)])
|
100 | 100 |
|
101 |
| -def object_into_not_containing_union(): |
| 101 | +def test_object_into_not_containing_union(): |
102 | 102 | expect_fails_rule(PossibleFragmentSpreads, '''
|
103 | 103 | fragment invalidObjectWithinUnion on CatOrDog { ...humanFragment }
|
104 | 104 | fragment humanFragment on Human { pets { name } }
|
105 | 105 | ''', [error('humanFragment', 'CatOrDog', 'Human', 2, 55)])
|
106 | 106 |
|
107 |
| -def union_into_not_contained_object(): |
| 107 | +def test_union_into_not_contained_object(): |
108 | 108 | expect_fails_rule(PossibleFragmentSpreads, '''
|
109 | 109 | fragment invalidUnionWithinObject on Human { ...catOrDogFragment }
|
110 | 110 | fragment catOrDogFragment on CatOrDog { __typename }
|
111 | 111 | ''', [error('catOrDogFragment', 'Human', 'CatOrDog', 2, 52)])
|
112 | 112 |
|
113 |
| -def union_into_non_overlapping_interface(): |
| 113 | +def test_union_into_non_overlapping_interface(): |
114 | 114 | expect_fails_rule(PossibleFragmentSpreads, '''
|
115 | 115 | fragment invalidUnionWithinInterface on Pet { ...humanOrAlienFragment }
|
116 | 116 | fragment humanOrAlienFragment on HumanOrAlien { __typename }
|
117 | 117 | ''', [error('humanOrAlienFragment', 'Pet', 'HumanOrAlien', 2, 53)])
|
118 | 118 |
|
119 |
| -def union_into_non_overlapping_union(): |
| 119 | +def test_union_into_non_overlapping_union(): |
120 | 120 | expect_fails_rule(PossibleFragmentSpreads, '''
|
121 | 121 | fragment invalidUnionWithinUnion on CatOrDog { ...humanOrAlienFragment }
|
122 | 122 | fragment humanOrAlienFragment on HumanOrAlien { __typename }
|
123 | 123 | ''', [error('humanOrAlienFragment', 'CatOrDog', 'HumanOrAlien', 2, 54)]);
|
124 | 124 |
|
125 |
| -def interface_into_non_implementing_object(): |
| 125 | +def test_interface_into_non_implementing_object(): |
126 | 126 | expect_fails_rule(PossibleFragmentSpreads, '''
|
127 | 127 | fragment invalidInterfaceWithinObject on Cat { ...intelligentFragment }
|
128 | 128 | fragment intelligentFragment on Intelligent { iq }
|
129 | 129 | ''', [error('intelligentFragment', 'Cat', 'Intelligent', 2, 54)])
|
130 | 130 |
|
131 |
| -def interface_into_non_overlapping_interface(): |
| 131 | +def test_interface_into_non_overlapping_interface(): |
132 | 132 | expect_fails_rule(PossibleFragmentSpreads, '''
|
133 | 133 | fragment invalidInterfaceWithinInterface on Pet {
|
134 | 134 | ...intelligentFragment
|
135 | 135 | }
|
136 | 136 | fragment intelligentFragment on Intelligent { iq }
|
137 | 137 | ''', [error('intelligentFragment', 'Pet', 'Intelligent', 3, 9)]);
|
138 | 138 |
|
139 |
| -def interface_into_non_overlapping_interface_in_inline_fragment(): |
| 139 | +def test_interface_into_non_overlapping_interface_in_inline_fragment(): |
140 | 140 | expect_fails_rule(PossibleFragmentSpreads, '''
|
141 | 141 | fragment invalidInterfaceWithinInterfaceAnon on Pet {
|
142 | 142 | ...on Intelligent { iq }
|
143 | 143 | }
|
144 | 144 | ''', [error_anon('Pet', 'Intelligent', 3, 9)]);
|
145 | 145 |
|
146 |
| -def interface_into_non_overlapping_union(): |
| 146 | +def test_interface_into_non_overlapping_union(): |
147 | 147 | expect_fails_rule(PossibleFragmentSpreads, '''
|
148 | 148 | fragment invalidInterfaceWithinUnion on HumanOrAlien { ...petFragment }
|
149 | 149 | fragment petFragment on Pet { name }
|
|
0 commit comments