mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-29 09:30:07 +03:00
TestFieldMapping is the more appropriate test class
This commit is contained in:
parent
8d8ba719e4
commit
ad2a9f7ed8
|
@ -53,6 +53,15 @@ class TestFieldMapping(TestCase):
|
||||||
with self.subTest(field=field):
|
with self.subTest(field=field):
|
||||||
assert inspector._map_field(field) == mapping
|
assert inspector._map_field(field) == mapping
|
||||||
|
|
||||||
|
def test_lazy_string_field(self):
|
||||||
|
class Serializer(serializers.Serializer):
|
||||||
|
text = serializers.CharField(help_text=_('lazy string'))
|
||||||
|
|
||||||
|
inspector = AutoSchema()
|
||||||
|
|
||||||
|
data = inspector._map_serializer(Serializer())
|
||||||
|
assert isinstance(data['properties']['text']['description'], str), "description must be str"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(uritemplate is None, reason='uritemplate not installed.')
|
@pytest.mark.skipif(uritemplate is None, reason='uritemplate not installed.')
|
||||||
class TestOperationIntrospection(TestCase):
|
class TestOperationIntrospection(TestCase):
|
||||||
|
@ -274,15 +283,6 @@ class TestOperationIntrospection(TestCase):
|
||||||
assert response_schema['ip']['type'] == 'string'
|
assert response_schema['ip']['type'] == 'string'
|
||||||
assert 'format' not in response_schema['ip']
|
assert 'format' not in response_schema['ip']
|
||||||
|
|
||||||
def test_lazy_string_field(self):
|
|
||||||
class Serializer(serializers.Serializer):
|
|
||||||
text = serializers.CharField(help_text=_('lazy string'))
|
|
||||||
|
|
||||||
inspector = AutoSchema()
|
|
||||||
|
|
||||||
data = inspector._map_serializer(Serializer())
|
|
||||||
assert isinstance(data['properties']['text']['description'], str), "description must be str"
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(uritemplate is None, reason='uritemplate not installed.')
|
@pytest.mark.skipif(uritemplate is None, reason='uritemplate not installed.')
|
||||||
@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.openapi.AutoSchema'})
|
@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.openapi.AutoSchema'})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user