44
55from graphene .relay import Node
66
7- from .fixtures import setup_fixtures
7+ from .setup import fixtures
88from .models import Article , Reporter
99from .types import (ArticleNode ,
1010 EditorNode ,
1313 ChildNode ,)
1414from ..fields import MongoengineConnectionField
1515
16- setup_fixtures ()
17-
1816
1917def get_nodes (data , key ):
2018 return map (lambda edge : edge ['node' ], data [key ]['edges' ])
2119
2220
23- def test_should_query_reporter ():
21+ def test_should_query_reporter (fixtures ):
2422
2523 class Query (graphene .ObjectType ):
2624 node = Node .Field ()
@@ -115,7 +113,7 @@ def resolve_reporter(self, *args, **kwargs):
115113 assert dict (result .data ['reporter' ]) == expected ['reporter' ]
116114
117115
118- def test_should_query_all_editors ():
116+ def test_should_query_all_editors (fixtures ):
119117
120118 class Query (graphene .ObjectType ):
121119 node = Node .Field ()
@@ -168,7 +166,7 @@ class Query(graphene.ObjectType):
168166 assert dict (result .data ['allEditors' ]) == expected ['allEditors' ]
169167
170168
171- def test_should_filter_editors_by_id ():
169+ def test_should_filter_editors_by_id (fixtures ):
172170
173171 class Query (graphene .ObjectType ):
174172 node = Node .Field ()
@@ -207,55 +205,7 @@ class Query(graphene.ObjectType):
207205 assert dict (result .data ['allEditors' ]) == expected ['allEditors' ]
208206
209207
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 ):
259209
260210 class Query (graphene .ObjectType ):
261211 node = Node .Field ()
@@ -295,7 +245,7 @@ class Query(graphene.ObjectType):
295245 assert result .data == expected
296246
297247
298- def test_should_filter_by_reference_field ():
248+ def test_should_filter_by_reference_field (fixtures ):
299249
300250 class Query (graphene .ObjectType ):
301251 node = Node .Field ()
@@ -335,7 +285,7 @@ class Query(graphene.ObjectType):
335285 assert result .data == expected
336286
337287
338- def test_should_filter_through_inheritance ():
288+ def test_should_filter_through_inheritance (fixtures ):
339289
340290 class Query (graphene .ObjectType ):
341291 node = Node .Field ()
@@ -372,7 +322,7 @@ class Query(graphene.ObjectType):
372322 expected , sort_keys = True )
373323
374324
375- def test_should_get_node_by_id ():
325+ def test_should_get_node_by_id (fixtures ):
376326 # Notes: https://goo.gl/hMNRgs
377327 class Query (graphene .ObjectType ):
378328 reporter = Node .Field (ReporterNode )
@@ -398,7 +348,7 @@ class Query(graphene.ObjectType):
398348 assert result .data == expected
399349
400350
401- def test_should_first_n ():
351+ def test_should_first_n (fixtures ):
402352
403353 class Query (graphene .ObjectType ):
404354
@@ -454,7 +404,7 @@ class Query(graphene.ObjectType):
454404 for item in get_nodes (expected , 'editors' ))
455405
456406
457- def test_should_after ():
407+ def test_should_after (fixtures ):
458408 class Query (graphene .ObjectType ):
459409
460410 players = MongoengineConnectionField (PlayerNode )
@@ -497,7 +447,7 @@ class Query(graphene.ObjectType):
497447 expected , sort_keys = True )
498448
499449
500- def test_should_before ():
450+ def test_should_before (fixtures ):
501451 class Query (graphene .ObjectType ):
502452
503453 players = MongoengineConnectionField (PlayerNode )
@@ -540,7 +490,7 @@ class Query(graphene.ObjectType):
540490 expected , sort_keys = True )
541491
542492
543- def test_should_last_n ():
493+ def test_should_last_n (fixtures ):
544494 class Query (graphene .ObjectType ):
545495 players = MongoengineConnectionField (PlayerNode )
546496
@@ -582,7 +532,7 @@ class Query(graphene.ObjectType):
582532 expected , sort_keys = True )
583533
584534
585- def test_should_self_reference ():
535+ def test_should_self_reference (fixtures ):
586536
587537 class Query (graphene .ObjectType ):
588538
@@ -681,8 +631,3 @@ class Query(graphene.ObjectType):
681631 assert not result .errors
682632 assert json .dumps (result .data , sort_keys = True ) == json .dumps (
683633 expected , sort_keys = True )
684-
685-
686- # TODO:
687- def test_should_paging ():
688- pass
0 commit comments