|
4 | 4 |
|
5 | 5 | from .setup import fixtures
|
6 | 6 | from .models import (
|
7 |
| - Child, Editor, Player, Reporter, ProfessorVector |
| 7 | + Child, Editor, Player, Reporter, ProfessorVector, Parent, CellTower |
8 | 8 | )
|
9 | 9 | from .types import (
|
10 |
| - ChildType, EditorType, PlayerType, ReporterType, ProfessorVectorType |
| 10 | + ChildType, EditorType, PlayerType, ReporterType, ProfessorVectorType, ParentType, CellTowerType |
11 | 11 | )
|
12 | 12 |
|
13 | 13 |
|
@@ -310,3 +310,48 @@ def resolve_children(self, *args, **kwargs):
|
310 | 310 | assert not result.errors
|
311 | 311 | assert json.dumps(result.data, sort_keys=True) == \
|
312 | 312 | json.dumps(expected, sort_keys=True)
|
| 313 | + |
| 314 | + |
| 315 | +def test_should_query_cell_tower(fixtures): |
| 316 | + |
| 317 | + class Query(graphene.ObjectType): |
| 318 | + |
| 319 | + cell_towers = graphene.List(CellTowerType) |
| 320 | + |
| 321 | + def resolve_cell_towers(self, *args, **kwargs): |
| 322 | + return list(CellTower.objects.all()) |
| 323 | + |
| 324 | + query = ''' |
| 325 | + query Query { |
| 326 | + cellTowers { |
| 327 | + code, |
| 328 | + coverageArea { |
| 329 | + type, |
| 330 | + coordinates |
| 331 | + } |
| 332 | + } |
| 333 | + } |
| 334 | + ''' |
| 335 | + expected = { |
| 336 | + 'cellTowers': [ |
| 337 | + { |
| 338 | + 'code': 'bar', |
| 339 | + 'coverageArea': { |
| 340 | + 'type': 'MultiPolygon', |
| 341 | + 'coordinates': [[[ |
| 342 | + [-43.36556, -22.99669], |
| 343 | + [-43.36539, -23.01928], |
| 344 | + [-43.26583, -23.01802], |
| 345 | + [-43.36717, -22.98855], |
| 346 | + [-43.36636, -22.99351], |
| 347 | + [-43.36556, -22.99669]]]] |
| 348 | + } |
| 349 | + } |
| 350 | + ] |
| 351 | + } |
| 352 | + |
| 353 | + schema = graphene.Schema(query=Query) |
| 354 | + result = schema.execute(query) |
| 355 | + assert not result.errors |
| 356 | + assert json.dumps(result.data, sort_keys=True) == \ |
| 357 | + json.dumps(expected, sort_keys=True) |
0 commit comments