@@ -25,7 +25,6 @@ def get_nodes(data, key):
25
25
def test_should_query_reporter (fixtures ):
26
26
27
27
class Query (graphene .ObjectType ):
28
- node = Node .Field ()
29
28
reporter = graphene .Field (ReporterNode )
30
29
31
30
def resolve_reporter (self , * args , ** kwargs ):
@@ -132,7 +131,6 @@ def resolve_reporter(self, *args, **kwargs):
132
131
def test_should_query_reporters_with_nested_document (fixtures ):
133
132
134
133
class Query (graphene .ObjectType ):
135
- node = Node .Field ()
136
134
reporters = MongoengineConnectionField (ReporterNode )
137
135
138
136
query = '''
@@ -156,40 +154,45 @@ class Query(graphene.ObjectType):
156
154
}
157
155
'''
158
156
expected = {
159
- 'reporter' : {
160
- 'firstName' : 'Allen' ,
161
- 'lastName' : 'Iverson' ,
162
-
163
- 'articles' : {
164
- 'edges' : [
165
- {
166
- 'node' : {
167
- 'headline' : 'Hello'
157
+ 'reporters' : {
158
+ 'edges' : [
159
+ {
160
+ 'node' : {
161
+ 'firstName' : 'Allen' ,
162
+ 'lastName' : 'Iverson' ,
163
+
164
+ 'articles' : {
165
+ 'edges' : [
166
+ {
167
+ 'node' : {
168
+ 'headline' : 'Hello'
169
+ }
170
+ }
171
+ ]
168
172
}
169
173
}
170
- ]
171
- }
174
+ }
175
+ ]
172
176
}
173
177
}
174
178
175
- print (query , expected )
176
- # schema = graphene.Schema(query=Query)
177
- # result = schema.execute(query)
178
- # assert not result.errors
179
- # print(dict(result.data['reporters']))
180
- # assert json.dumps(result.data['reporter'], sort_keys=True) \
181
- # == json.dumps( expected['reporter'], sort_keys=True)
179
+ # print(query, expected)
180
+ schema = graphene .Schema (query = Query )
181
+ result = schema .execute (query )
182
+ assert not result .errors
183
+ # import json
184
+ # print( json.dumps(result.data['reporters']))
185
+ assert result . data [ 'reporters' ] == expected ['reporters' ]
182
186
183
187
184
188
def test_should_query_all_editors (fixtures , fixtures_dirname ):
185
189
186
190
class Query (graphene .ObjectType ):
187
- node = Node .Field ()
188
- all_editors = MongoengineConnectionField (EditorNode )
191
+ editors = MongoengineConnectionField (EditorNode )
189
192
190
193
query = '''
191
194
query EditorQuery {
192
- allEditors {
195
+ editors {
193
196
edges {
194
197
node {
195
198
id,
@@ -211,7 +214,7 @@ class Query(graphene.ObjectType):
211
214
data = base64 .b64encode (f .read ())
212
215
213
216
expected = {
214
- 'allEditors ' : {
217
+ 'editors ' : {
215
218
'edges' : [
216
219
{
217
220
'node' : {
@@ -256,7 +259,7 @@ class Query(graphene.ObjectType):
256
259
schema = graphene .Schema (query = Query )
257
260
result = schema .execute (query )
258
261
assert not result .errors
259
- assert result .data ['allEditors ' ] == expected ['allEditors ' ]
262
+ assert result .data ['editors ' ] == expected ['editors ' ]
260
263
261
264
262
265
def test_should_filter_editors_by_id (fixtures ):
0 commit comments