Skip to content

Commit bf7bb7d

Browse files
committed
minor: Simplify test code
1 parent f579bc1 commit bf7bb7d

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

graphene_mongo/tests/test_relay_query.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class Query(graphene.ObjectType):
2222
reporter = graphene.Field(nodes.ReporterNode)
2323

2424
def resolve_reporter(self, *args, **kwargs):
25-
print('abc' * 10)
2625
return models.Reporter.objects.first()
2726

2827
query = '''
@@ -120,7 +119,7 @@ def resolve_reporter(self, *args, **kwargs):
120119
schema = graphene.Schema(query=Query)
121120
result = schema.execute(query)
122121
assert not result.errors
123-
assert result.data['reporter'] == expected['reporter']
122+
assert result.data == expected
124123

125124

126125
def test_should_query_reporters_with_nested_document(fixtures):
@@ -174,7 +173,7 @@ class Query(graphene.ObjectType):
174173
schema = graphene.Schema(query=Query)
175174
result = schema.execute(query)
176175
assert not result.errors
177-
assert result.data['reporters'] == expected['reporters']
176+
assert result.data == expected
178177

179178

180179
def test_should_query_all_editors(fixtures, fixtures_dirname):
@@ -251,10 +250,10 @@ class Query(graphene.ObjectType):
251250
schema = graphene.Schema(query=Query)
252251
result = schema.execute(query)
253252
assert not result.errors
254-
assert result.data['editors'] == expected['editors']
255-
253+
assert result.data == expected
256254

257255

256+
"""
258257
def test_should_query_editors_with_dataloader(fixtures):
259258
from promise import Promise
260259
from promise.dataloader import DataLoader
@@ -274,13 +273,13 @@ def batch_load_fn(self, keys):
274273
editor_loader = EditorLoader()
275274
276275
class Query(graphene.ObjectType):
277-
editors = MongoengineConnectionField(nodes.EditorNode)
276+
# editors = MongoengineConnectionField(nodes.EditorNode)
277+
editors = graphene.List(types.EditorType)
278278
279-
"""
280279
def resolve_editors(self, info, **args):
281280
print(self.__dict__)
282281
return None
283-
"""
282+
284283
285284
query = '''
286285
query EditorPromiseQuery {
@@ -299,17 +298,17 @@ def resolve_editors(self, info, **args):
299298
schema = graphene.Schema(query=Query)
300299
result = schema.execute(query)
301300
print(result.data)
301+
"""
302302

303303

304304
def test_should_filter_editors_by_id(fixtures):
305305

306306
class Query(graphene.ObjectType):
307-
node = Node.Field()
308-
all_editors = MongoengineConnectionField(nodes.EditorNode)
307+
editors = MongoengineConnectionField(nodes.EditorNode)
309308

310309
query = '''
311310
query EditorQuery {
312-
allEditors(id: "RWRpdG9yTm9kZToy") {
311+
editors(id: "RWRpdG9yTm9kZToy") {
313312
edges {
314313
node {
315314
id,
@@ -321,7 +320,7 @@ class Query(graphene.ObjectType):
321320
}
322321
'''
323322
expected = {
324-
'allEditors': {
323+
'editors': {
325324
'edges': [
326325
{
327326
'node': {
@@ -337,13 +336,12 @@ class Query(graphene.ObjectType):
337336
schema = graphene.Schema(query=Query)
338337
result = schema.execute(query)
339338
assert not result.errors
340-
assert dict(result.data['allEditors']) == expected['allEditors']
339+
assert result.data == expected
341340

342341

343342
def test_should_filter(fixtures):
344343

345344
class Query(graphene.ObjectType):
346-
node = Node.Field()
347345
articles = MongoengineConnectionField(nodes.ArticleNode)
348346

349347
query = '''
@@ -385,7 +383,6 @@ class Query(graphene.ObjectType):
385383
def test_should_filter_by_reference_field(fixtures):
386384

387385
class Query(graphene.ObjectType):
388-
node = Node.Field()
389386
articles = MongoengineConnectionField(nodes.ArticleNode)
390387

391388
query = '''

0 commit comments

Comments
 (0)