11from functools import partial
22
3- from graphql .language import parse
43from graphql .utilities import build_schema
5- from graphql .validation import validate , KnownDirectivesRule
4+ from graphql .validation import KnownDirectivesRule
65from graphql .validation .rules .known_directives import (
76 unknown_directive_message , misplaced_directive_message )
87
98from .harness import (
10- expect_fails_rule , expect_passes_rule , expect_sdl_errors_from_rule ,
11- test_schema )
12-
9+ expect_fails_rule , expect_passes_rule , expect_sdl_errors_from_rule )
1310
1411expect_sdl_errors = partial (
1512 expect_sdl_errors_from_rule , KnownDirectivesRule )
@@ -112,17 +109,12 @@ def with_well_placed_directives():
112109 }
113110 """ )
114111
115- def with_well_placed_variable_definition_directives ():
116- # Need to parse with experimental flag
117- query_string = """
112+ def experimental_with_well_placed_variable_definition_directive ():
113+ expect_passes_rule (KnownDirectivesRule , """
118114 query Foo($var: Boolean @onVariableDefinition) {
119115 name
120116 }
121- """
122- errors = validate (test_schema , parse (
123- query_string , experimental_variable_definition_directives = True ),
124- [KnownDirectivesRule ])
125- assert errors == [], 'Should validate'
117+ """ , experimental_variable_definition_directives = True )
126118
127119 def with_misplaced_directives ():
128120 expect_fails_rule (KnownDirectivesRule , """
@@ -141,20 +133,14 @@ def with_misplaced_directives():
141133 misplaced_directive ('onQuery' , 'mutation' , 7 , 26 ),
142134 ])
143135
144- def with_misplaced_variable_definition_directives ():
145- # Need to parse with experimental flag
146- query_string = """
136+ def experimental_with_misplaced_variable_definition_directive ():
137+ expect_fails_rule (KnownDirectivesRule , """
147138 query Foo($var: Boolean @onField) {
148139 name
149140 }
150- """
151- errors = validate (test_schema , parse (
152- query_string , experimental_variable_definition_directives = True ),
153- [KnownDirectivesRule ])
154- expected_errors = [
155- misplaced_directive ('onField' , 'variable definition' , 2 , 37 )]
156- assert len (errors ) >= 1 , 'Should not validate'
157- assert errors == expected_errors
141+ """ , [
142+ misplaced_directive ('onField' , 'variable definition' , 2 , 37 )],
143+ experimental_variable_definition_directives = True )
158144
159145 def describe_within_sdl ():
160146
0 commit comments