|
1 | 1 | from textwrap import dedent
|
2 | 2 |
|
3 |
| -from graphene.compat.middleware import enum_value_convertor_middleware |
4 |
| - |
5 | 3 | from ..argument import Argument
|
6 | 4 | from ..enum import Enum, PyEnum
|
7 | 5 | from ..field import Field
|
@@ -473,101 +471,3 @@ class Query(ObjectType):
|
473 | 471 | assert result.data == {"createPaint": {"color": "RED"}}
|
474 | 472 |
|
475 | 473 | assert color_input_value == RGB.RED
|
476 |
| - |
477 |
| - |
478 |
| -def test_mutation_enum_input_compatability_middleware(): |
479 |
| - """Test the `enum_value_convertor_middleware`""" |
480 |
| - |
481 |
| - class RGB(Enum): |
482 |
| - """Available colors""" |
483 |
| - |
484 |
| - RED = 1 |
485 |
| - GREEN = 2 |
486 |
| - BLUE = 3 |
487 |
| - |
488 |
| - color_input = None |
489 |
| - |
490 |
| - class CreatePaint(Mutation): |
491 |
| - class Arguments: |
492 |
| - color = RGB(required=True) |
493 |
| - |
494 |
| - color = RGB(required=True) |
495 |
| - |
496 |
| - def mutate(_, info, color): |
497 |
| - nonlocal color_input |
498 |
| - color_input = color |
499 |
| - return CreatePaint(color=color) |
500 |
| - |
501 |
| - class MyMutation(ObjectType): |
502 |
| - create_paint = CreatePaint.Field() |
503 |
| - |
504 |
| - class Query(ObjectType): |
505 |
| - a = String() |
506 |
| - |
507 |
| - schema = Schema(query=Query, mutation=MyMutation) |
508 |
| - result = schema.execute( |
509 |
| - """ mutation MyMutation { |
510 |
| - createPaint(color: RED) { |
511 |
| - color |
512 |
| - } |
513 |
| - } |
514 |
| - """, |
515 |
| - middleware=[enum_value_convertor_middleware], |
516 |
| - ) |
517 |
| - assert not result.errors |
518 |
| - assert result.data == {"createPaint": {"color": "RED"}} |
519 |
| - |
520 |
| - assert color_input == 1 |
521 |
| - assert type(color_input) == int |
522 |
| - |
523 |
| - |
524 |
| -def test_mutation_enum_input_compatability_middleware_input_type(): |
525 |
| - """Test the `enum_value_convertor_middleware`""" |
526 |
| - |
527 |
| - class RGB(Enum): |
528 |
| - """Available colors""" |
529 |
| - |
530 |
| - RED = 1 |
531 |
| - GREEN = 2 |
532 |
| - BLUE = 3 |
533 |
| - |
534 |
| - class SecondColorInput(InputObjectType): |
535 |
| - color = RGB(required=True) |
536 |
| - |
537 |
| - class ColorInput(InputObjectType): |
538 |
| - color_input = SecondColorInput(required=True) |
539 |
| - |
540 |
| - color_input_value = None |
541 |
| - |
542 |
| - class CreatePaint(Mutation): |
543 |
| - class Arguments: |
544 |
| - color_input = ColorInput(required=True) |
545 |
| - |
546 |
| - color = RGB(required=True) |
547 |
| - |
548 |
| - def mutate(_, info, color_input): |
549 |
| - nonlocal color_input_value |
550 |
| - color_input_value = color_input.color_input.color |
551 |
| - return CreatePaint(color=color_input_value) |
552 |
| - |
553 |
| - class MyMutation(ObjectType): |
554 |
| - create_paint = CreatePaint.Field() |
555 |
| - |
556 |
| - class Query(ObjectType): |
557 |
| - a = String() |
558 |
| - |
559 |
| - schema = Schema(query=Query, mutation=MyMutation) |
560 |
| - result = schema.execute( |
561 |
| - """ mutation MyMutation { |
562 |
| - createPaint(colorInput: { colorInput: { color: RED } }) { |
563 |
| - color |
564 |
| - } |
565 |
| - } |
566 |
| - """, |
567 |
| - middleware=[enum_value_convertor_middleware], |
568 |
| - ) |
569 |
| - assert not result.errors |
570 |
| - assert result.data == {"createPaint": {"color": "RED"}} |
571 |
| - |
572 |
| - assert color_input_value == 1 |
573 |
| - assert type(color_input_value) == int |
0 commit comments