|
1 | 1 |
|
2 | 2 | from ..abstracttype import AbstractType
|
3 | 3 | from ..field import Field
|
| 4 | +from ..argument import Argument |
4 | 5 | from ..inputfield import InputField
|
| 6 | +from ..objecttype import ObjectType |
5 | 7 | from ..inputobjecttype import InputObjectType
|
6 | 8 | from ..unmountedtype import UnmountedType
|
7 | 9 |
|
@@ -61,6 +63,22 @@ class MyInputObjectType(InputObjectType):
|
61 | 63 | assert isinstance(MyInputObjectType._meta.fields['field'], InputField)
|
62 | 64 |
|
63 | 65 |
|
| 66 | +def test_generate_inputobjecttype_as_argument(): |
| 67 | + class MyInputObjectType(InputObjectType): |
| 68 | + field = MyScalar() |
| 69 | + |
| 70 | + class MyObjectType(ObjectType): |
| 71 | + field = Field(MyType, input=MyInputObjectType()) |
| 72 | + |
| 73 | + assert 'field' in MyObjectType._meta.fields |
| 74 | + field = MyObjectType._meta.fields['field'] |
| 75 | + assert isinstance(field, Field) |
| 76 | + assert field.type == MyType |
| 77 | + assert 'input' in field.args |
| 78 | + assert isinstance(field.args['input'], Argument) |
| 79 | + assert field.args['input'].type == MyInputObjectType |
| 80 | + |
| 81 | + |
64 | 82 | def test_generate_inputobjecttype_inherit_abstracttype():
|
65 | 83 | class MyAbstractType(AbstractType):
|
66 | 84 | field1 = MyScalar(MyType)
|
|
0 commit comments