11from pytest import raises
22
33from graphql .language import DirectiveLocation , DirectiveDefinitionNode , Node
4- from graphql .type import (
5- GraphQLArgument ,
6- GraphQLDirective ,
7- GraphQLInt ,
8- GraphQLString ,
9- GraphQLSkipDirective ,
10- is_directive ,
11- is_specified_directive ,
12- )
4+ from graphql .type import GraphQLArgument , GraphQLDirective , GraphQLInt , GraphQLString
135
146
157def describe_type_system_directive ():
@@ -77,19 +69,19 @@ def directive_has_repr():
7769 directive = GraphQLDirective ("foo" , [])
7870 assert repr (directive ) == "<GraphQLDirective(@foo)>"
7971
80- def reject_an_unnamed_directivce ():
72+ def rejects_an_unnamed_directive ():
8173 with raises (TypeError ) as exc_info :
8274 # noinspection PyTypeChecker
8375 GraphQLDirective (None , locations = []) # type: ignore
8476 assert str (exc_info .value ) == "Directive must be named."
8577
86- def reject_directive_with_incorrectly_typed_name ():
78+ def rejects_a_directive_with_incorrectly_typed_name ():
8779 with raises (TypeError ) as exc_info :
8880 # noinspection PyTypeChecker
8981 GraphQLDirective ({"bad" : True }, locations = []) # type: ignore
9082 assert str (exc_info .value ) == "The directive name must be a string."
9183
92- def reject_directive_with_incorrectly_typed_args ():
84+ def rejects_a_directive_with_incorrectly_typed_args ():
9385 with raises (TypeError ) as exc_info :
9486 # noinspection PyTypeChecker
9587 GraphQLDirective ("Foo" , locations = [], args = ["arg" ]) # type: ignore
@@ -113,13 +105,13 @@ def reject_directive_with_incorrectly_typed_args():
113105 "Foo args must be GraphQLArgument or input type objects."
114106 )
115107
116- def reject_directive_with_undefined_locations ():
108+ def rejects_a_directive_with_undefined_locations ():
117109 with raises (TypeError ) as exc_info :
118110 # noinspection PyTypeChecker
119111 GraphQLDirective ("Foo" , locations = None ) # type: ignore
120112 assert str (exc_info .value ) == "Foo locations must be a list/tuple."
121113
122- def recect_directive_with_incorrectly_typed_locations ():
114+ def recects_a_directive_with_incorrectly_typed_locations ():
123115 with raises (TypeError ) as exc_info :
124116 # noinspection PyTypeChecker
125117 GraphQLDirective ("Foo" , locations = "bad" ) # type: ignore
@@ -131,43 +123,18 @@ def recect_directive_with_incorrectly_typed_locations():
131123 "Foo locations must be DirectiveLocation objects."
132124 )
133125
134- def reject_directive_with_incorrectly_typed_description ():
126+ def rejects_a_directive_with_incorrectly_typed_description ():
135127 with raises (TypeError ) as exc_info :
136128 # noinspection PyTypeChecker
137129 GraphQLDirective (
138130 "Foo" , locations = [], description = {"bad" : True }
139131 ) # type: ignore
140132 assert str (exc_info .value ) == "Foo description must be a string."
141133
142- def reject_directive_with_incorrectly_typed_ast_node ():
134+ def rejects_a_directive_with_incorrectly_typed_ast_node ():
143135 with raises (TypeError ) as exc_info :
144136 # noinspection PyTypeChecker
145137 GraphQLDirective ("Foo" , locations = [], ast_node = Node ()) # type: ignore
146138 assert str (exc_info .value ) == (
147139 "Foo AST node must be a DirectiveDefinitionNode."
148140 )
149-
150-
151- def describe_directive_predicates ():
152- def describe_is_directive ():
153- def returns_true_for_directive ():
154- directive = GraphQLDirective ("Foo" , [])
155- assert is_directive (directive ) is True
156-
157- def returns_false_for_type_class_rather_than_instance ():
158- assert is_directive (GraphQLDirective ) is False
159-
160- def returns_false_for_other_instances ():
161- assert is_directive (GraphQLString ) is False
162-
163- def returns_false_for_random_garbage ():
164- assert is_directive (None ) is False
165- assert is_directive ({"what" : "is this" }) is False
166-
167- def describe_is_specified_directive ():
168- def returns_true_for_specified_directive ():
169- assert is_specified_directive (GraphQLSkipDirective ) is True
170-
171- def returns_false_for_unspecified_directive ():
172- directive = GraphQLDirective ("Foo" , [])
173- assert is_specified_directive (directive ) is False
0 commit comments