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