1
1
from pytest import raises
2
2
3
3
from 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
13
5
14
6
15
7
def describe_type_system_directive ():
@@ -77,19 +69,19 @@ def directive_has_repr():
77
69
directive = GraphQLDirective ("foo" , [])
78
70
assert repr (directive ) == "<GraphQLDirective(@foo)>"
79
71
80
- def reject_an_unnamed_directivce ():
72
+ def rejects_an_unnamed_directive ():
81
73
with raises (TypeError ) as exc_info :
82
74
# noinspection PyTypeChecker
83
75
GraphQLDirective (None , locations = []) # type: ignore
84
76
assert str (exc_info .value ) == "Directive must be named."
85
77
86
- def reject_directive_with_incorrectly_typed_name ():
78
+ def rejects_a_directive_with_incorrectly_typed_name ():
87
79
with raises (TypeError ) as exc_info :
88
80
# noinspection PyTypeChecker
89
81
GraphQLDirective ({"bad" : True }, locations = []) # type: ignore
90
82
assert str (exc_info .value ) == "The directive name must be a string."
91
83
92
- def reject_directive_with_incorrectly_typed_args ():
84
+ def rejects_a_directive_with_incorrectly_typed_args ():
93
85
with raises (TypeError ) as exc_info :
94
86
# noinspection PyTypeChecker
95
87
GraphQLDirective ("Foo" , locations = [], args = ["arg" ]) # type: ignore
@@ -113,13 +105,13 @@ def reject_directive_with_incorrectly_typed_args():
113
105
"Foo args must be GraphQLArgument or input type objects."
114
106
)
115
107
116
- def reject_directive_with_undefined_locations ():
108
+ def rejects_a_directive_with_undefined_locations ():
117
109
with raises (TypeError ) as exc_info :
118
110
# noinspection PyTypeChecker
119
111
GraphQLDirective ("Foo" , locations = None ) # type: ignore
120
112
assert str (exc_info .value ) == "Foo locations must be a list/tuple."
121
113
122
- def recect_directive_with_incorrectly_typed_locations ():
114
+ def recects_a_directive_with_incorrectly_typed_locations ():
123
115
with raises (TypeError ) as exc_info :
124
116
# noinspection PyTypeChecker
125
117
GraphQLDirective ("Foo" , locations = "bad" ) # type: ignore
@@ -131,43 +123,18 @@ def recect_directive_with_incorrectly_typed_locations():
131
123
"Foo locations must be DirectiveLocation objects."
132
124
)
133
125
134
- def reject_directive_with_incorrectly_typed_description ():
126
+ def rejects_a_directive_with_incorrectly_typed_description ():
135
127
with raises (TypeError ) as exc_info :
136
128
# noinspection PyTypeChecker
137
129
GraphQLDirective (
138
130
"Foo" , locations = [], description = {"bad" : True }
139
131
) # type: ignore
140
132
assert str (exc_info .value ) == "Foo description must be a string."
141
133
142
- def reject_directive_with_incorrectly_typed_ast_node ():
134
+ def rejects_a_directive_with_incorrectly_typed_ast_node ():
143
135
with raises (TypeError ) as exc_info :
144
136
# noinspection PyTypeChecker
145
137
GraphQLDirective ("Foo" , locations = [], ast_node = Node ()) # type: ignore
146
138
assert str (exc_info .value ) == (
147
139
"Foo AST node must be a DirectiveDefinitionNode."
148
140
)
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