3
3
import json
4
4
import graphene
5
5
6
+ from . import models
7
+ from . import types
6
8
from .setup import fixtures , fixtures_dirname
7
- from .models import (
8
- Child , Editor , Player , Reporter , ProfessorVector , Parent , CellTower
9
- )
10
- from .types import (
11
- ChildType , EditorType , PlayerType , ReporterType , ProfessorVectorType , ParentType , CellTowerType
12
- )
13
9
14
10
15
11
def test_should_query_editor (fixtures , fixtures_dirname ):
16
12
17
13
class Query (graphene .ObjectType ):
18
14
19
- editor = graphene .Field (EditorType )
20
- editors = graphene .List (EditorType )
15
+ editor = graphene .Field (types . EditorType )
16
+ editors = graphene .List (types . EditorType )
21
17
22
18
def resolve_editor (self , * args , ** kwargs ):
23
- return Editor .objects .first ()
19
+ return models . Editor .objects .first ()
24
20
25
21
def resolve_editors (self , * args , ** kwargs ):
26
- return list (Editor .objects .all ())
22
+ return list (models . Editor .objects .all ())
27
23
28
24
query = '''
29
25
query EditorQuery {
@@ -91,10 +87,10 @@ def resolve_editors(self, *args, **kwargs):
91
87
def test_should_query_reporter (fixtures ):
92
88
93
89
class Query (graphene .ObjectType ):
94
- reporter = graphene .Field (ReporterType )
90
+ reporter = graphene .Field (types . ReporterType )
95
91
96
92
def resolve_reporter (self , * args , ** kwargs ):
97
- return Reporter .objects .first ()
93
+ return models . Reporter .objects .first ()
98
94
99
95
query = '''
100
96
query ReporterQuery {
@@ -154,10 +150,10 @@ def test_should_custom_kwargs(fixtures):
154
150
155
151
class Query (graphene .ObjectType ):
156
152
157
- editors = graphene .List (EditorType , first = graphene .Int ())
153
+ editors = graphene .List (types . EditorType , first = graphene .Int ())
158
154
159
155
def resolve_editors (self , * args , ** kwargs ):
160
- editors = Editor .objects ()
156
+ editors = models . Editor .objects ()
161
157
if 'first' in kwargs :
162
158
editors = editors [:kwargs ['first' ]]
163
159
return list (editors )
@@ -192,10 +188,10 @@ def test_should_self_reference(fixtures):
192
188
193
189
class Query (graphene .ObjectType ):
194
190
195
- all_players = graphene .List (PlayerType )
191
+ all_players = graphene .List (types . PlayerType )
196
192
197
193
def resolve_all_players (self , * args , ** kwargs ):
198
- return Player .objects .all ()
194
+ return models . Player .objects .all ()
199
195
200
196
query = '''
201
197
query PlayersQuery {
@@ -260,10 +256,10 @@ def resolve_all_players(self, *args, **kwargs):
260
256
def test_should_query_with_embedded_document (fixtures ):
261
257
262
258
class Query (graphene .ObjectType ):
263
- professor_vector = graphene .Field (ProfessorVectorType , id = graphene .String ())
259
+ professor_vector = graphene .Field (types . ProfessorVectorType , id = graphene .String ())
264
260
265
261
def resolve_professor_vector (self , info , id ):
266
- return ProfessorVector .objects (metadata__id = id ).first ()
262
+ return models . ProfessorVector .objects (metadata__id = id ).first ()
267
263
268
264
query = """
269
265
query {
@@ -284,7 +280,8 @@ def resolve_professor_vector(self, info, id):
284
280
}
285
281
}
286
282
}
287
- schema = graphene .Schema (query = Query , types = [ProfessorVectorType ])
283
+ schema = graphene .Schema (
284
+ query = Query , types = [types .ProfessorVectorType ])
288
285
result = schema .execute (query )
289
286
assert not result .errors
290
287
assert result .data == expected
@@ -294,10 +291,10 @@ def test_should_query_child(fixtures):
294
291
295
292
class Query (graphene .ObjectType ):
296
293
297
- children = graphene .List (ChildType )
294
+ children = graphene .List (types . ChildType )
298
295
299
296
def resolve_children (self , * args , ** kwargs ):
300
- return list (Child .objects .all ())
297
+ return list (models . Child .objects .all ())
301
298
302
299
query = '''
303
300
query Query {
@@ -338,10 +335,10 @@ def test_should_query_cell_tower(fixtures):
338
335
339
336
class Query (graphene .ObjectType ):
340
337
341
- cell_towers = graphene .List (CellTowerType )
338
+ cell_towers = graphene .List (types . CellTowerType )
342
339
343
340
def resolve_cell_towers (self , * args , ** kwargs ):
344
- return list (CellTower .objects .all ())
341
+ return list (models . CellTower .objects .all ())
345
342
346
343
query = '''
347
344
query Query {
0 commit comments