mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 04:20:12 +03:00
Add test for new setting
This commit is contained in:
parent
4a200d5e66
commit
4b09e82402
|
@ -516,6 +516,11 @@ class Test4605Regression(TestCase):
|
|||
assert prefix == '/'
|
||||
|
||||
|
||||
class CustomViewInspector(AutoSchema):
|
||||
"""A dummy AutoSchema subclass"""
|
||||
pass
|
||||
|
||||
|
||||
class TestAutoSchema(TestCase):
|
||||
|
||||
def test_apiview_schema_descriptor(self):
|
||||
|
@ -523,6 +528,18 @@ class TestAutoSchema(TestCase):
|
|||
assert hasattr(view, 'schema')
|
||||
assert isinstance(view.schema, AutoSchema)
|
||||
|
||||
def test_set_custom_inspector_class_on_view(self):
|
||||
class CustomView(APIView):
|
||||
schema = CustomViewInspector()
|
||||
|
||||
view = CustomView()
|
||||
assert isinstance(view.schema, CustomViewInspector)
|
||||
|
||||
def test_set_custom_inspector_class_via_settings(self):
|
||||
with override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS':'tests.test_schemas.CustomViewInspector'}):
|
||||
view = APIView()
|
||||
assert isinstance(view.schema, CustomViewInspector)
|
||||
|
||||
def test_get_link_requires_instance(self):
|
||||
descriptor = APIView.schema # Accessed from class
|
||||
with pytest.raises(AssertionError):
|
||||
|
|
Loading…
Reference in New Issue
Block a user