|
| 1 | +from collections import OrderedDict |
| 2 | + |
1 | 3 | from promise import Promise
|
2 |
| -from collections import namedtuple |
3 |
| -from pytest import raises |
4 | 4 | from graphql import graphql
|
5 | 5 | from graphql.type import (
|
6 | 6 | GraphQLSchema,
|
@@ -83,22 +83,6 @@ def test_requires_an_argument():
|
83 | 83 | }
|
84 | 84 | }
|
85 | 85 | '''
|
86 |
| - expected = { |
87 |
| - 'allObjects': [ |
88 |
| - { |
89 |
| - 'id': 'VXNlcjox' |
90 |
| - }, |
91 |
| - { |
92 |
| - 'id': 'VXNlcjoy' |
93 |
| - }, |
94 |
| - { |
95 |
| - 'id': 'UGhvdG86MQ==' |
96 |
| - }, |
97 |
| - { |
98 |
| - 'id': 'UGhvdG86Mg==' |
99 |
| - }, |
100 |
| - ] |
101 |
| - } |
102 | 86 | result = graphql(schema, query)
|
103 | 87 | assert len(result.errors) == 1
|
104 | 88 |
|
@@ -333,96 +317,103 @@ def test_contains_correct_field():
|
333 | 317 | }
|
334 | 318 | }
|
335 | 319 | '''
|
336 |
| - |
337 | 320 | expected = {
|
338 | 321 | '__schema': {
|
339 | 322 | 'mutationType': {
|
340 | 323 | 'fields': [
|
341 | 324 | {
|
342 |
| - 'name': 'simpleMutation', |
| 325 | + 'name': 'simplePromiseMutation', |
343 | 326 | 'args': [
|
344 | 327 | {
|
345 | 328 | 'name': 'input',
|
346 | 329 | 'type': {
|
347 | 330 | 'name': None,
|
348 | 331 | 'kind': 'NON_NULL',
|
349 | 332 | 'ofType': {
|
350 |
| - 'name': 'SimpleMutationInput', |
| 333 | + 'name': 'SimplePromiseMutationInput', |
351 | 334 | 'kind': 'INPUT_OBJECT'
|
352 | 335 | }
|
353 | 336 | },
|
354 | 337 | }
|
355 | 338 | ],
|
356 | 339 | 'type': {
|
357 |
| - 'name': 'SimpleMutationPayload', |
| 340 | + 'name': 'SimplePromiseMutationPayload', |
358 | 341 | 'kind': 'OBJECT',
|
359 | 342 | }
|
360 | 343 | },
|
361 | 344 | {
|
362 |
| - 'name': 'simpleMutationWithThunkFields', |
| 345 | + 'name': 'simpleRootValueMutation', |
363 | 346 | 'args': [
|
364 | 347 | {
|
365 | 348 | 'name': 'input',
|
366 | 349 | 'type': {
|
367 | 350 | 'name': None,
|
368 | 351 | 'kind': 'NON_NULL',
|
369 | 352 | 'ofType': {
|
370 |
| - 'name': 'SimpleMutationWithThunkFieldsInput', |
| 353 | + 'name': 'SimpleRootValueMutationInput', |
371 | 354 | 'kind': 'INPUT_OBJECT'
|
372 | 355 | }
|
373 | 356 | },
|
374 | 357 | }
|
375 | 358 | ],
|
376 | 359 | 'type': {
|
377 |
| - 'name': 'SimpleMutationWithThunkFieldsPayload', |
| 360 | + 'name': 'SimpleRootValueMutationPayload', |
378 | 361 | 'kind': 'OBJECT',
|
379 | 362 | }
|
380 | 363 | },
|
381 | 364 | {
|
382 |
| - 'name': 'simplePromiseMutation', |
| 365 | + 'name': 'simpleMutation', |
383 | 366 | 'args': [
|
384 | 367 | {
|
385 | 368 | 'name': 'input',
|
386 | 369 | 'type': {
|
387 | 370 | 'name': None,
|
388 | 371 | 'kind': 'NON_NULL',
|
389 | 372 | 'ofType': {
|
390 |
| - 'name': 'SimplePromiseMutationInput', |
| 373 | + 'name': 'SimpleMutationInput', |
391 | 374 | 'kind': 'INPUT_OBJECT'
|
392 | 375 | }
|
393 | 376 | },
|
394 | 377 | }
|
395 | 378 | ],
|
396 | 379 | 'type': {
|
397 |
| - 'name': 'SimplePromiseMutationPayload', |
| 380 | + 'name': 'SimpleMutationPayload', |
398 | 381 | 'kind': 'OBJECT',
|
399 | 382 | }
|
400 | 383 | },
|
401 | 384 | {
|
402 |
| - 'name': 'simpleRootValueMutation', |
| 385 | + 'name': 'simpleMutationWithThunkFields', |
403 | 386 | 'args': [
|
404 | 387 | {
|
405 | 388 | 'name': 'input',
|
406 | 389 | 'type': {
|
407 | 390 | 'name': None,
|
408 | 391 | 'kind': 'NON_NULL',
|
409 | 392 | 'ofType': {
|
410 |
| - 'name': 'SimpleRootValueMutationInput', |
| 393 | + 'name': 'SimpleMutationWithThunkFieldsInput', |
411 | 394 | 'kind': 'INPUT_OBJECT'
|
412 | 395 | }
|
413 | 396 | },
|
414 | 397 | }
|
415 | 398 | ],
|
416 | 399 | 'type': {
|
417 |
| - 'name': 'SimpleRootValueMutationPayload', |
| 400 | + 'name': 'SimpleMutationWithThunkFieldsPayload', |
418 | 401 | 'kind': 'OBJECT',
|
419 | 402 | }
|
420 | 403 | },
|
421 | 404 | ]
|
422 | 405 | }
|
423 | 406 | }
|
424 |
| - |
425 | 407 | }
|
426 | 408 | result = graphql(schema, query)
|
427 | 409 | assert not result.errors
|
| 410 | + # ensure the ordering is correct for the assertion |
| 411 | + expected['__schema']['mutationType']['fields'] = sorted( |
| 412 | + expected['__schema']['mutationType']['fields'], |
| 413 | + key=lambda k: k['name'] |
| 414 | + ) |
| 415 | + result.data['__schema']['mutationType']['fields'] = sorted( |
| 416 | + result.data['__schema']['mutationType']['fields'], |
| 417 | + key=lambda k: k['name'] |
| 418 | + ) |
428 | 419 | assert result.data == expected
|
0 commit comments