diff options
| author | Tom Christie | 2013-05-18 07:06:21 -0700 |
|---|---|---|
| committer | Tom Christie | 2013-05-18 07:06:21 -0700 |
| commit | ea9a3d88bce5507af753a79b259e6bd8e53a9059 (patch) | |
| tree | b30b8d4fa780e7e7c7858d8a8234cd10d447186c /rest_framework/tests/serializer.py | |
| parent | 80a2600891aab2211c8c4bf3ce78e3c1d5c6de72 (diff) | |
| parent | 208bd991dacb6c2edc9fc820717354c579c2e6d6 (diff) | |
| download | django-rest-framework-ea9a3d88bce5507af753a79b259e6bd8e53a9059.tar.bz2 | |
Merge pull request #859 from craigds/master
fix for #765
Diffstat (limited to 'rest_framework/tests/serializer.py')
| -rw-r--r-- | rest_framework/tests/serializer.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/rest_framework/tests/serializer.py b/rest_framework/tests/serializer.py index d0a8570c..2264a638 100644 --- a/rest_framework/tests/serializer.py +++ b/rest_framework/tests/serializer.py @@ -91,6 +91,17 @@ class PersonSerializer(serializers.ModelSerializer): read_only_fields = ('age',) +class NestedSerializer(serializers.Serializer): + info = serializers.Field() + + +class ModelSerializerWithNestedSerializer(serializers.ModelSerializer): + nested = NestedSerializer(source='*') + + class Meta: + model = Person + + class PersonSerializerInvalidReadOnly(serializers.ModelSerializer): """ Testing for #652. @@ -418,6 +429,17 @@ class ValidationTests(TestCase): except: self.fail('Wrong exception type thrown.') + def test_writable_star_source_on_nested_serializer(self): + """ + Assert that a nested serializer instantiated with source='*' correctly + expands the data into the outer serializer. + """ + serializer = ModelSerializerWithNestedSerializer(data={ + 'name': 'marko', + 'nested': {'info': 'hi'}}, + ) + self.assertEqual(serializer.is_valid(), True) + class CustomValidationTests(TestCase): class CommentSerializerWithFieldValidator(CommentSerializer): |
