8
8
from ..types import DictType
9
9
10
10
11
- def _get_type (rest_framework_field , ** kwargs ):
11
+ def _get_type (rest_framework_field , is_input = True , ** kwargs ):
12
12
# prevents the following error:
13
13
# AssertionError: The `source` argument is not meaningful when applied to a `child=` field.
14
14
# Remove `source=` from the field declaration.
@@ -19,7 +19,7 @@ def _get_type(rest_framework_field, **kwargs):
19
19
20
20
field = rest_framework_field (** kwargs )
21
21
22
- return convert_serializer_field (field )
22
+ return convert_serializer_field (field , is_input = is_input )
23
23
24
24
25
25
def assert_conversion (rest_framework_field , graphene_field , ** kwargs ):
@@ -40,18 +40,6 @@ def test_should_unknown_rest_framework_field_raise_exception():
40
40
assert 'Don\' t know how to convert the serializer field' in str (excinfo .value )
41
41
42
42
43
- def test_should_date_convert_string ():
44
- assert_conversion (serializers .DateField , graphene .String )
45
-
46
-
47
- def test_should_time_convert_string ():
48
- assert_conversion (serializers .TimeField , graphene .String )
49
-
50
-
51
- def test_should_date_time_convert_string ():
52
- assert_conversion (serializers .DateTimeField , graphene .String )
53
-
54
-
55
43
def test_should_char_convert_string ():
56
44
assert_conversion (serializers .CharField , graphene .String )
57
45
@@ -85,6 +73,28 @@ def test_should_uuid_convert_string():
85
73
assert_conversion (serializers .UUIDField , graphene .String )
86
74
87
75
76
+ def test_should_model_convert_field ():
77
+
78
+ class MyModelSerializer (serializers .ModelSerializer ):
79
+ class Meta :
80
+ model = None
81
+ fields = '__all__'
82
+
83
+ assert_conversion (MyModelSerializer , graphene .Field , is_input = False )
84
+
85
+
86
+ def test_should_date_time_convert_datetime ():
87
+ assert_conversion (serializers .DateTimeField , graphene .types .datetime .DateTime )
88
+
89
+
90
+ def test_should_date_convert_datetime ():
91
+ assert_conversion (serializers .DateField , graphene .types .datetime .DateTime )
92
+
93
+
94
+ def test_should_time_convert_time ():
95
+ assert_conversion (serializers .TimeField , graphene .types .datetime .Time )
96
+
97
+
88
98
def test_should_integer_convert_int ():
89
99
assert_conversion (serializers .IntegerField , graphene .Int )
90
100
0 commit comments