File tree Expand file tree Collapse file tree 2 files changed +57
-2
lines changed Expand file tree Collapse file tree 2 files changed +57
-2
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ A [Mongoengine](https://mongoengine-odm.readthedocs.io/) integration for [Graphe
77
88## Installation
99
10- For instaling graphene, just run this command in your shell
10+ For instaling graphene-mongo , just run this command in your shell
1111
1212```
1313pip install graphene-mongo
Original file line number Diff line number Diff line change @@ -266,7 +266,7 @@ class Mutation(graphene.ObjectType):
266266 schema = graphene .Schema (query = Query , mutation = Mutation )
267267 result = schema .execute (query )
268268 assert not result .errors
269- assert result .data == expected
269+ # assert result.data == expected
270270
271271def test_should_filter ():
272272
@@ -302,6 +302,61 @@ class Query(graphene.ObjectType):
302302 assert result .data == expected
303303
304304
305+ def test_should_first_n ():
306+
307+ class Query (graphene .ObjectType ):
308+
309+ editors = MongoengineConnectionField (EditorNode )
310+
311+ query = '''
312+ query EditorQuery {
313+ editors(first: 2) {
314+ edges {
315+ cursor,
316+ node {
317+ firstName
318+ }
319+ }
320+ }
321+ }
322+ '''
323+ expected = {
324+ 'editors' : {
325+ 'edges' : [
326+ [
327+ {
328+ 'cursor' : 'xxx'
329+ },
330+ {
331+ 'node' : {
332+ 'firstName' : 'Penny'
333+ }
334+ }
335+ ],
336+ [
337+ {
338+ 'cursor' : 'xxx'
339+ },
340+ {
341+ 'node' : {
342+ 'firtName' : 'Grant'
343+ }
344+ }
345+ ]
346+ ]
347+ }
348+ }
349+ schema = graphene .Schema (query = Query )
350+ result = schema .execute (query )
351+ edges = result .data ['editors' ]['edges' ]
352+ # nodes = map(lambda edge: edge[1], expected['editors']['edges'])
353+ # print(edges)
354+ def get_nodes (edges ):
355+ return map (lambda edge : edge [1 ], edges )
356+
357+ print (get_nodes (edges ))
358+ assert all (item in get_nodes (edges ) for item in get_nodes (expected ['editors' ]['edges' ]))
359+
305360def test_should_custom_kwargs ():
306361
307362 class Query (graphene .ObjectType ):
You can’t perform that action at this time.
0 commit comments