|
7 | 7 | from django.urls import include, path
|
8 | 8 |
|
9 | 9 | from rest_framework import (
|
10 |
| - filters, generics, pagination, permissions, serializers |
| 10 | + RemovedInDRF317Warning, 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
|
@@ -1433,3 +1441,46 @@ def test_schema_handles_exception():
|
1433 | 1441 | response.render()
|
1434 | 1442 | assert response.status_code == 403
|
1435 | 1443 | assert b"You do not have permission to perform this action." in response.content
|
| 1444 | + |
| 1445 | + |
| 1446 | +@pytest.mark.skipif(not coreapi, reason='coreapi is not installed') |
| 1447 | +def test_coreapi_deprecation(): |
| 1448 | + with pytest.warns(RemovedInDRF317Warning): |
| 1449 | + SchemaGenerator() |
| 1450 | + |
| 1451 | + with pytest.warns(RemovedInDRF317Warning): |
| 1452 | + AutoSchema() |
| 1453 | + |
| 1454 | + with pytest.warns(RemovedInDRF317Warning): |
| 1455 | + ManualSchema({}) |
| 1456 | + |
| 1457 | + with pytest.warns(RemovedInDRF317Warning): |
| 1458 | + deprecated_filter = OrderingFilter() |
| 1459 | + deprecated_filter.get_schema_fields({}) |
| 1460 | + |
| 1461 | + with pytest.warns(RemovedInDRF317Warning): |
| 1462 | + deprecated_filter = BaseFilterBackend() |
| 1463 | + deprecated_filter.get_schema_fields({}) |
| 1464 | + |
| 1465 | + with pytest.warns(RemovedInDRF317Warning): |
| 1466 | + deprecated_filter = SearchFilter() |
| 1467 | + deprecated_filter.get_schema_fields({}) |
| 1468 | + |
| 1469 | + with pytest.warns(RemovedInDRF317Warning): |
| 1470 | + paginator = BasePagination() |
| 1471 | + paginator.get_schema_fields({}) |
| 1472 | + |
| 1473 | + with pytest.warns(RemovedInDRF317Warning): |
| 1474 | + paginator = PageNumberPagination() |
| 1475 | + paginator.get_schema_fields({}) |
| 1476 | + |
| 1477 | + with pytest.warns(RemovedInDRF317Warning): |
| 1478 | + paginator = LimitOffsetPagination() |
| 1479 | + paginator.get_schema_fields({}) |
| 1480 | + |
| 1481 | + with pytest.warns(RemovedInDRF317Warning): |
| 1482 | + paginator = CursorPagination() |
| 1483 | + paginator.get_schema_fields({}) |
| 1484 | + |
| 1485 | + with pytest.warns(RemovedInDRF317Warning): |
| 1486 | + is_enabled() |
0 commit comments