Move model meta test to 'test_model_serializer'

This commit is contained in:
Ryan P Kilby 2019-09-03 11:10:07 -07:00
parent 474145512a
commit 98ab1c8139
2 changed files with 2 additions and 17 deletions

View File

@ -89,6 +89,7 @@ class FieldOptionsModel(models.Model):
default_field = models.IntegerField(default=0)
descriptive_field = models.IntegerField(help_text='Some help text', verbose_name='A label')
choices_field = models.CharField(max_length=100, choices=COLOR_CHOICES)
text_choices_field = models.TextField(choices=COLOR_CHOICES)
class ChoicesModel(models.Model):
@ -211,6 +212,7 @@ class TestRegularFieldMappings(TestCase):
default_field = IntegerField(required=False)
descriptive_field = IntegerField(help_text='Some help text', label='A label')
choices_field = ChoiceField(choices=(('red', 'Red'), ('blue', 'Blue'), ('green', 'Green')))
text_choices_field = ChoiceField(choices=(('red', 'Red'), ('blue', 'Blue'), ('green', 'Green')))
""")
self.assertEqual(repr(TestSerializer()), expected)

View File

@ -1,7 +1,6 @@
from unittest import mock
from django.conf.urls import url
from django.db import models
from django.test import TestCase, override_settings
from rest_framework.decorators import action
@ -9,7 +8,6 @@ from rest_framework.routers import SimpleRouter
from rest_framework.serializers import ModelSerializer
from rest_framework.utils import json
from rest_framework.utils.breadcrumbs import get_breadcrumbs
from rest_framework.utils.field_mapping import get_field_kwargs
from rest_framework.utils.formatting import lazy_format
from rest_framework.utils.urls import remove_query_param, replace_query_param
from rest_framework.views import APIView
@ -269,18 +267,3 @@ class LazyFormatTests(TestCase):
assert message.format.call_count == 1
str(formatted)
assert message.format.call_count == 1
class GetFieldKwargsTest(TestCase):
def test_get_text_field_kwargs(self):
# TextField without choices
f = models.TextField()
kwargs = get_field_kwargs('f', f)
assert 'style' in kwargs
assert 'choices' not in kwargs
# TextField with choices
f = models.TextField(choices=['ONE', 'TWO'])
kwargs = get_field_kwargs('f', f)
assert 'style' not in kwargs
assert 'choices' in kwargs