4
4
5
5
from graphene .relay import Node
6
6
7
- from .fixtures import setup_fixtures
7
+ from .setup import fixtures
8
8
from .models import Article , Reporter
9
9
from .types import (ArticleNode ,
10
10
EditorNode ,
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 (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 (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 (fixtures ):
172
170
173
171
class Query (graphene .ObjectType ):
174
172
node = Node .Field ()
@@ -207,55 +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
- headline = graphene .String ()
216
-
217
- article = graphene .Field (ArticleNode )
218
-
219
- def mutate (self , info , headline ):
220
- article = Article (
221
- headline = headline
222
- )
223
- article .save ()
224
-
225
- return CreateArticle (article = article )
226
-
227
- class Query (graphene .ObjectType ):
228
- node = Node .Field ()
229
-
230
- class Mutation (graphene .ObjectType ):
231
-
232
- create_article = CreateArticle .Field ()
233
-
234
- query = '''
235
- mutation ArticleCreator {
236
- createArticle(
237
- headline: "My Article"
238
- ) {
239
- article {
240
- headline
241
- }
242
- }
243
- }
244
- '''
245
- expected = {
246
- 'createArticle' : {
247
- 'article' : {
248
- 'headline' : 'My Article'
249
- }
250
- }
251
- }
252
- schema = graphene .Schema (query = Query , mutation = Mutation )
253
- result = schema .execute (query )
254
- assert not result .errors
255
- assert result .data == expected
256
-
257
-
258
- def test_should_filter ():
208
+ def test_should_filter (fixtures ):
259
209
260
210
class Query (graphene .ObjectType ):
261
211
node = Node .Field ()
@@ -295,7 +245,7 @@ class Query(graphene.ObjectType):
295
245
assert result .data == expected
296
246
297
247
298
- def test_should_filter_by_reference_field ():
248
+ def test_should_filter_by_reference_field (fixtures ):
299
249
300
250
class Query (graphene .ObjectType ):
301
251
node = Node .Field ()
@@ -335,7 +285,7 @@ class Query(graphene.ObjectType):
335
285
assert result .data == expected
336
286
337
287
338
- def test_should_filter_through_inheritance ():
288
+ def test_should_filter_through_inheritance (fixtures ):
339
289
340
290
class Query (graphene .ObjectType ):
341
291
node = Node .Field ()
@@ -372,7 +322,7 @@ class Query(graphene.ObjectType):
372
322
expected , sort_keys = True )
373
323
374
324
375
- def test_should_get_node_by_id ():
325
+ def test_should_get_node_by_id (fixtures ):
376
326
# Notes: https://goo.gl/hMNRgs
377
327
class Query (graphene .ObjectType ):
378
328
reporter = Node .Field (ReporterNode )
@@ -398,7 +348,7 @@ class Query(graphene.ObjectType):
398
348
assert result .data == expected
399
349
400
350
401
- def test_should_first_n ():
351
+ def test_should_first_n (fixtures ):
402
352
403
353
class Query (graphene .ObjectType ):
404
354
@@ -454,7 +404,7 @@ class Query(graphene.ObjectType):
454
404
for item in get_nodes (expected , 'editors' ))
455
405
456
406
457
- def test_should_after ():
407
+ def test_should_after (fixtures ):
458
408
class Query (graphene .ObjectType ):
459
409
460
410
players = MongoengineConnectionField (PlayerNode )
@@ -497,7 +447,7 @@ class Query(graphene.ObjectType):
497
447
expected , sort_keys = True )
498
448
499
449
500
- def test_should_before ():
450
+ def test_should_before (fixtures ):
501
451
class Query (graphene .ObjectType ):
502
452
503
453
players = MongoengineConnectionField (PlayerNode )
@@ -540,7 +490,7 @@ class Query(graphene.ObjectType):
540
490
expected , sort_keys = True )
541
491
542
492
543
- def test_should_last_n ():
493
+ def test_should_last_n (fixtures ):
544
494
class Query (graphene .ObjectType ):
545
495
players = MongoengineConnectionField (PlayerNode )
546
496
@@ -582,7 +532,7 @@ class Query(graphene.ObjectType):
582
532
expected , sort_keys = True )
583
533
584
534
585
- def test_should_self_reference ():
535
+ def test_should_self_reference (fixtures ):
586
536
587
537
class Query (graphene .ObjectType ):
588
538
@@ -681,8 +631,3 @@ class Query(graphene.ObjectType):
681
631
assert not result .errors
682
632
assert json .dumps (result .data , sort_keys = True ) == json .dumps (
683
633
expected , sort_keys = True )
684
-
685
-
686
- # TODO:
687
- def test_should_paging ():
688
- pass
0 commit comments