diff --git a/tests/test_schemas.py b/tests/test_schemas.py index ba561a959..6de875521 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -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):