mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 17:09:59 +03:00
fix test
This commit is contained in:
parent
d8c6821563
commit
a8a90d9e9a
|
@ -1,5 +1,5 @@
|
||||||
import pytest
|
import pytest
|
||||||
from django.conf.urls import url
|
from django.conf.urls import include, url
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.test import RequestFactory, TestCase, override_settings
|
from django.test import RequestFactory, TestCase, override_settings
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
@ -698,21 +698,19 @@ class TestOperationIntrospection(TestCase):
|
||||||
serializer_class = ExampleSerializer
|
serializer_class = ExampleSerializer
|
||||||
queryset = ExampleModel.objects.none()
|
queryset = ExampleModel.objects.none()
|
||||||
|
|
||||||
from django.urls import path, include
|
|
||||||
|
|
||||||
router = routers.DefaultRouter()
|
router = routers.DefaultRouter()
|
||||||
router.register(r'example', ExampleViewSet)
|
router.register(r'example', ExampleViewSet)
|
||||||
|
|
||||||
generator = SchemaGenerator(patterns=[
|
generator = SchemaGenerator(patterns=[
|
||||||
path(r'api/', include(router.urls))
|
url(r'api/', include(router.urls))
|
||||||
])
|
])
|
||||||
generator._initialise_endpoints()
|
generator._initialise_endpoints()
|
||||||
|
|
||||||
schema = generator.get_schema(request=None, public=True)
|
schema = generator.get_schema(request=None, public=True)
|
||||||
|
|
||||||
assert list(schema['paths']['/api/example/'].keys()) == ['get', 'post']
|
assert sorted(schema['paths']['/api/example/'].keys()) == ['get', 'post']
|
||||||
assert list(schema['paths']['/api/example/{id}/'].keys()) == ['get', 'put', 'patch', 'delete']
|
assert sorted(schema['paths']['/api/example/{id}/'].keys()) == ['delete', 'get', 'patch', 'put']
|
||||||
assert list(schema['components']['schemas'].keys()) == ['Example', 'PatchedExample']
|
assert sorted(schema['components']['schemas'].keys()) == ['Example', 'PatchedExample']
|
||||||
# TODO do more checks
|
# TODO do more checks
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user