13
13
ChildNode ,)
14
14
from ..fields import MongoengineConnectionField
15
15
16
- setup_fixtures ()
17
-
18
16
19
17
def get_nodes (data , key ):
20
18
return map (lambda edge : edge ['node' ], data [key ]['edges' ])
21
19
22
20
23
- def test_should_query_reporter ():
21
+ def test_should_query_reporter (setup_fixtures ):
24
22
25
23
class Query (graphene .ObjectType ):
26
24
node = Node .Field ()
@@ -115,7 +113,7 @@ def resolve_reporter(self, *args, **kwargs):
115
113
assert dict (result .data ['reporter' ]) == expected ['reporter' ]
116
114
117
115
118
- def test_should_query_all_editors ():
116
+ def test_should_query_all_editors (setup_fixtures ):
119
117
120
118
class Query (graphene .ObjectType ):
121
119
node = Node .Field ()
@@ -168,7 +166,7 @@ class Query(graphene.ObjectType):
168
166
assert dict (result .data ['allEditors' ]) == expected ['allEditors' ]
169
167
170
168
171
- def test_should_filter_editors_by_id ():
169
+ def test_should_filter_editors_by_id (setup_fixtures ):
172
170
173
171
class Query (graphene .ObjectType ):
174
172
node = Node .Field ()
@@ -207,57 +205,7 @@ class Query(graphene.ObjectType):
207
205
assert dict (result .data ['allEditors' ]) == expected ['allEditors' ]
208
206
209
207
210
- def test_should_mutate ():
211
-
212
- class CreateArticle (graphene .Mutation ):
213
-
214
- class Arguments :
215
-
216
- headline = graphene .String ()
217
-
218
- article = graphene .Field (ArticleNode )
219
-
220
- def mutate (self , info , headline ):
221
- article = Article (
222
- headline = headline
223
- )
224
- article .save ()
225
-
226
- return CreateArticle (article = article )
227
-
228
- class Query (graphene .ObjectType ):
229
-
230
- node = Node .Field ()
231
-
232
- class Mutation (graphene .ObjectType ):
233
-
234
- create_article = CreateArticle .Field ()
235
-
236
- query = '''
237
- mutation ArticleCreator {
238
- createArticle(
239
- headline: "My Article"
240
- ) {
241
- article {
242
- headline
243
- }
244
- }
245
- }
246
- '''
247
- expected = {
248
- 'createArticle' : {
249
- 'article' : {
250
- 'headline' : 'My Article'
251
- }
252
- }
253
- }
254
- schema = graphene .Schema (query = Query , mutation = Mutation )
255
- result = schema .execute (query )
256
- assert not result .errors
257
- assert result .data == expected
258
-
259
-
260
- def test_should_filter ():
208
+ def test_should_filter (setup_fixtures ):
261
209
262
210
class Query (graphene .ObjectType ):
263
211
node = Node .Field ()
@@ -297,7 +245,7 @@ class Query(graphene.ObjectType):
297
245
assert result .data == expected
298
246
299
247
300
- def test_should_filter_by_reference_field ():
248
+ def test_should_filter_by_reference_field (setup_fixtures ):
301
249
302
250
class Query (graphene .ObjectType ):
303
251
node = Node .Field ()
@@ -337,7 +285,7 @@ class Query(graphene.ObjectType):
337
285
assert result .data == expected
338
286
339
287
340
- def test_should_filter_through_inheritance ():
288
+ def test_should_filter_through_inheritance (setup_fixtures ):
341
289
342
290
class Query (graphene .ObjectType ):
343
291
node = Node .Field ()
@@ -374,7 +322,7 @@ class Query(graphene.ObjectType):
374
322
expected , sort_keys = True )
375
323
376
324
377
- def test_should_get_node_by_id ():
325
+ def test_should_get_node_by_id (setup_fixtures ):
378
326
# Notes: https://goo.gl/hMNRgs
379
327
class Query (graphene .ObjectType ):
380
328
reporter = Node .Field (ReporterNode )
@@ -400,7 +348,7 @@ class Query(graphene.ObjectType):
400
348
assert result .data == expected
401
349
402
350
403
- def test_should_first_n ():
351
+ def test_should_first_n (setup_fixtures ):
404
352
405
353
class Query (graphene .ObjectType ):
406
354
@@ -456,7 +404,7 @@ class Query(graphene.ObjectType):
456
404
for item in get_nodes (expected , 'editors' ))
457
405
458
406
459
- def test_should_after ():
407
+ def test_should_after (setup_fixtures ):
460
408
class Query (graphene .ObjectType ):
461
409
462
410
players = MongoengineConnectionField (PlayerNode )
@@ -499,7 +447,7 @@ class Query(graphene.ObjectType):
499
447
expected , sort_keys = True )
500
448
501
449
502
- def test_should_before ():
450
+ def test_should_before (setup_fixtures ):
503
451
class Query (graphene .ObjectType ):
504
452
505
453
players = MongoengineConnectionField (PlayerNode )
@@ -542,7 +490,7 @@ class Query(graphene.ObjectType):
542
490
expected , sort_keys = True )
543
491
544
492
545
- def test_should_last_n ():
493
+ def test_should_last_n (setup_fixtures ):
546
494
class Query (graphene .ObjectType ):
547
495
players = MongoengineConnectionField (PlayerNode )
548
496
@@ -584,7 +532,7 @@ class Query(graphene.ObjectType):
584
532
expected , sort_keys = True )
585
533
586
534
587
- def test_should_self_reference ():
535
+ def test_should_self_reference (setup_fixtures ):
588
536
589
537
class Query (graphene .ObjectType ):
590
538
@@ -683,8 +631,3 @@ class Query(graphene.ObjectType):
683
631
assert not result .errors
684
632
assert json .dumps (result .data , sort_keys = True ) == json .dumps (
685
633
expected , sort_keys = True )
686
-
687
-
688
- # TODO:
689
- def test_should_paging ():
690
- pass
0 commit comments