Skip to content

Commit

Permalink
Merge branch 'master' of github.com:tomchristie/django-rest-framework
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie committed Jul 26, 2016
2 parents 19b415e + 5d3b56f commit f9df0dc
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_model_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,3 +955,24 @@ class Meta(TestSerializer.Meta):
self.assertEqual(unicode_repr(ChildSerializer()), child_expected)
self.assertEqual(unicode_repr(TestSerializer()), test_expected)
self.assertEqual(unicode_repr(ChildSerializer()), child_expected)


class OneToOneTargetTestModel(models.Model):
text = models.CharField(max_length=100)


class OneToOneSourceTestModel(models.Model):
target = models.OneToOneField(OneToOneTargetTestModel, primary_key=True)


class TestModelFieldValues(TestCase):
def test_model_field(self):
class ExampleSerializer(serializers.ModelSerializer):
class Meta:
model = OneToOneSourceTestModel
fields = ('target',)

target = OneToOneTargetTestModel(id=1, text='abc')
source = OneToOneSourceTestModel(target=target)
serializer = ExampleSerializer(source)
self.assertEqual(serializer.data, {'target': 1})

0 comments on commit f9df0dc

Please sign in to comment.