|
7 | 7 | from django.urls import include, path |
8 | 8 |
|
9 | 9 | from rest_framework import ( |
10 | | - filters, generics, pagination, permissions, serializers |
| 10 | + RemovedInDRF314Warning, filters, generics, pagination, permissions, |
| 11 | + serializers |
11 | 12 | ) |
12 | 13 | from rest_framework.compat import coreapi, coreschema |
13 | 14 | from rest_framework.decorators import action, api_view, schema |
| 15 | +from rest_framework.filters import ( |
| 16 | + BaseFilterBackend, OrderingFilter, SearchFilter |
| 17 | +) |
| 18 | +from rest_framework.pagination import ( |
| 19 | + BasePagination, CursorPagination, LimitOffsetPagination, |
| 20 | + PageNumberPagination |
| 21 | +) |
14 | 22 | from rest_framework.request import Request |
15 | 23 | from rest_framework.routers import DefaultRouter, SimpleRouter |
16 | 24 | from rest_framework.schemas import ( |
17 | 25 | AutoSchema, ManualSchema, SchemaGenerator, get_schema_view |
18 | 26 | ) |
19 | | -from rest_framework.schemas.coreapi import field_to_schema |
| 27 | +from rest_framework.schemas.coreapi import field_to_schema, is_enabled |
20 | 28 | from rest_framework.schemas.generators import EndpointEnumerator |
21 | 29 | from rest_framework.schemas.utils import is_list_view |
22 | 30 | from rest_framework.test import APIClient, APIRequestFactory |
@@ -1372,3 +1380,46 @@ def test_schema_handles_exception(): |
1372 | 1380 | response.render() |
1373 | 1381 | assert response.status_code == 403 |
1374 | 1382 | assert b"You do not have permission to perform this action." in response.content |
| 1383 | + |
| 1384 | + |
| 1385 | +@pytest.mark.skipif(not coreapi, reason='coreapi is not installed') |
| 1386 | +def test_coreapi_deprecation(): |
| 1387 | + with pytest.warns(RemovedInDRF314Warning): |
| 1388 | + SchemaGenerator() |
| 1389 | + |
| 1390 | + with pytest.warns(RemovedInDRF314Warning): |
| 1391 | + AutoSchema() |
| 1392 | + |
| 1393 | + with pytest.warns(RemovedInDRF314Warning): |
| 1394 | + ManualSchema({}) |
| 1395 | + |
| 1396 | + with pytest.warns(RemovedInDRF314Warning): |
| 1397 | + deprecated_filter = OrderingFilter() |
| 1398 | + deprecated_filter.get_schema_fields({}) |
| 1399 | + |
| 1400 | + with pytest.warns(RemovedInDRF314Warning): |
| 1401 | + deprecated_filter = BaseFilterBackend() |
| 1402 | + deprecated_filter.get_schema_fields({}) |
| 1403 | + |
| 1404 | + with pytest.warns(RemovedInDRF314Warning): |
| 1405 | + deprecated_filter = SearchFilter() |
| 1406 | + deprecated_filter.get_schema_fields({}) |
| 1407 | + |
| 1408 | + with pytest.warns(RemovedInDRF314Warning): |
| 1409 | + paginator = BasePagination() |
| 1410 | + paginator.get_schema_fields({}) |
| 1411 | + |
| 1412 | + with pytest.warns(RemovedInDRF314Warning): |
| 1413 | + paginator = PageNumberPagination() |
| 1414 | + paginator.get_schema_fields({}) |
| 1415 | + |
| 1416 | + with pytest.warns(RemovedInDRF314Warning): |
| 1417 | + paginator = LimitOffsetPagination() |
| 1418 | + paginator.get_schema_fields({}) |
| 1419 | + |
| 1420 | + with pytest.warns(RemovedInDRF314Warning): |
| 1421 | + paginator = CursorPagination() |
| 1422 | + paginator.get_schema_fields({}) |
| 1423 | + |
| 1424 | + with pytest.warns(RemovedInDRF314Warning): |
| 1425 | + is_enabled() |
0 commit comments