mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Add simplest possible failing test
This commit is contained in:
parent
3c1bf6bfd5
commit
4345894445
|
@ -557,39 +557,6 @@ class TestRelationalFieldMappings(TestCase):
|
|||
self.maxDiff = None
|
||||
self.assertEqual(unicode_repr(TestSerializer()), expected)
|
||||
|
||||
def test_nested_hyperlinked_relations_named_source(self):
|
||||
class TestSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = RelationalModel
|
||||
depth = 1
|
||||
fields = '__all__'
|
||||
|
||||
extra_kwargs = {
|
||||
'url': {
|
||||
'source': 'url'
|
||||
}}
|
||||
|
||||
expected = dedent("""
|
||||
TestSerializer():
|
||||
url = HyperlinkedIdentityField(source='url', view_name='relationalmodel-detail')
|
||||
foreign_key = NestedSerializer(read_only=True):
|
||||
url = HyperlinkedIdentityField(view_name='foreignkeytargetmodel-detail')
|
||||
name = CharField(max_length=100)
|
||||
one_to_one = NestedSerializer(read_only=True):
|
||||
url = HyperlinkedIdentityField(view_name='onetoonetargetmodel-detail')
|
||||
name = CharField(max_length=100)
|
||||
many_to_many = NestedSerializer(many=True, read_only=True):
|
||||
url = HyperlinkedIdentityField(view_name='manytomanytargetmodel-detail')
|
||||
name = CharField(max_length=100)
|
||||
through = NestedSerializer(many=True, read_only=True):
|
||||
url = HyperlinkedIdentityField(view_name='throughtargetmodel-detail')
|
||||
name = CharField(max_length=100)
|
||||
""")
|
||||
self.maxDiff = None
|
||||
self.assertEqual(unicode_repr(TestSerializer()), expected)
|
||||
|
||||
|
||||
|
||||
def test_nested_unique_together_relations(self):
|
||||
class TestSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
|
@ -1168,3 +1135,25 @@ class Test5004UniqueChoiceField(TestCase):
|
|||
serializer = TestUniqueChoiceSerializer(data={'name': 'choice1'})
|
||||
assert not serializer.is_valid()
|
||||
assert serializer.errors == {'name': ['unique choice model with this name already exists.']}
|
||||
|
||||
class TestFieldSource(TestCase):
|
||||
|
||||
def test_named_field_source(self):
|
||||
class TestSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = RegularFieldsModel
|
||||
fields = ('number_field',)
|
||||
extra_kwargs = {
|
||||
'number_field': {
|
||||
'source': 'integer_field'
|
||||
}
|
||||
}
|
||||
|
||||
expected = dedent("""
|
||||
TestSerializer():
|
||||
number_field = IntegerField(source='integer_field')
|
||||
""")
|
||||
self.maxDiff = None
|
||||
self.assertEqual(unicode_repr(TestSerializer()), expected)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user