|
4 | 4 |
|
5 | 5 | from .setup import fixtures
|
6 | 6 | from .models import (
|
7 |
| - Editor, Player, Reporter, ProfessorVector |
| 7 | + Child, Editor, Player, Reporter, ProfessorVector |
8 | 8 | )
|
9 | 9 | from .types import (
|
10 |
| - EditorType, PlayerType, ReporterType, ProfessorVectorType |
| 10 | + ChildType, EditorType, PlayerType, ReporterType, ProfessorVectorType |
11 | 11 | )
|
12 | 12 |
|
13 | 13 |
|
@@ -265,3 +265,43 @@ def resolve_professor_vector(self, info, id):
|
265 | 265 | assert not result.errors
|
266 | 266 | assert json.dumps(result.data, sort_keys=True) == \
|
267 | 267 | json.dumps(expected, sort_keys=True)
|
| 268 | + |
| 269 | + |
| 270 | +def test_should_query_child(fixtures): |
| 271 | + |
| 272 | + class Query(graphene.ObjectType): |
| 273 | + |
| 274 | + children = graphene.List(ChildType) |
| 275 | + |
| 276 | + def resolve_children(self, *args, **kwargs): |
| 277 | + return list(Child.objects.all()) |
| 278 | + |
| 279 | + query = ''' |
| 280 | + query Query { |
| 281 | + children { |
| 282 | + bar, |
| 283 | + baz, |
| 284 | + loc { |
| 285 | + type, |
| 286 | + coordinates |
| 287 | + } |
| 288 | + } |
| 289 | + } |
| 290 | + ''' |
| 291 | + expected = { |
| 292 | + 'editors': [{ |
| 293 | + }] |
| 294 | + } |
| 295 | + |
| 296 | + schema = graphene.Schema(query=Query) |
| 297 | + result = schema.execute(query) |
| 298 | + # assert not result.errors |
| 299 | + print('result.data', result.data) |
| 300 | + # print('abaw') |
| 301 | + print(ChildType._meta.fields) |
| 302 | + # metadata = result.data['editor'].pop('metadata') |
| 303 | + # expected_metadata = expected['editor'].pop('metadata') |
| 304 | + # assert(json.loads(metadata)) == dict(json.loads(expected_metadata)) |
| 305 | + # assert dict(result.data['editor']) == expected['editor'] |
| 306 | + # assert all(item in result.data['editors'] for item in expected['editors']) |
| 307 | + |
0 commit comments