mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-11-01 00:17:40 +03:00
* Standardize spelling to American English (only in .md files) * Update remaining British english spell words to American english style * Configures the codespell pre-commit hook to enforce US English consistency changes: - Activates the `en-GB_to_en-US` built-in dictionary to flag British spellings - Created codespell-ignore-words.txt file to ignore specific words - include `code` and `names` for comprehensive typo checking in technical contexts. - changed the 'lets' to 'let's'.
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from django.test import TestCase
|
|
from django.test.utils import override_settings
|
|
from django.urls import path
|
|
|
|
from rest_framework import serializers
|
|
from rest_framework.generics import ListCreateAPIView
|
|
from rest_framework.renderers import BrowsableAPIRenderer
|
|
|
|
|
|
class NestedSerializer(serializers.Serializer):
|
|
one = serializers.IntegerField(max_value=10)
|
|
two = serializers.IntegerField(max_value=10)
|
|
|
|
|
|
class NestedSerializerTestSerializer(serializers.Serializer):
|
|
nested = NestedSerializer()
|
|
|
|
|
|
class NestedSerializersView(ListCreateAPIView):
|
|
renderer_classes = (BrowsableAPIRenderer, )
|
|
serializer_class = NestedSerializerTestSerializer
|
|
queryset = [{'nested': {'one': 1, 'two': 2}}]
|
|
|
|
|
|
urlpatterns = [
|
|
path('api/', NestedSerializersView.as_view(), name='api'),
|
|
]
|
|
|
|
|
|
class DropdownWithAuthTests(TestCase):
|
|
"""Tests correct dropdown behavior with Auth views enabled."""
|
|
|
|
@override_settings(ROOT_URLCONF='tests.browsable_api.test_browsable_nested_api')
|
|
def test_login(self):
|
|
response = self.client.get('/api/')
|
|
assert 200 == response.status_code
|
|
content = response.content.decode()
|
|
assert 'form action="/api/"' in content
|
|
assert 'input name="nested.one"' in content
|
|
assert 'input name="nested.two"' in content
|