aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/relations_pk.py
diff options
context:
space:
mode:
authorTom Christie2013-01-18 21:29:21 +0000
committerTom Christie2013-01-18 21:29:21 +0000
commit211bb89eecfadd6831a0c59852926f16ea6bf733 (patch)
tree23592a21f3a67f1f96ad0e78e1a890d93559138e /rest_framework/tests/relations_pk.py
parent6385ac519defc8e434fd4e24a48a680845341cb7 (diff)
downloaddjango-rest-framework-211bb89eecfadd6831a0c59852926f16ea6bf733.tar.bz2
Raise Validation Errors when relationships receive incorrect types. Fixes #590.
Diffstat (limited to 'rest_framework/tests/relations_pk.py')
-rw-r--r--rest_framework/tests/relations_pk.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/rest_framework/tests/relations_pk.py b/rest_framework/tests/relations_pk.py
index dd1e86b5..3391e60a 100644
--- a/rest_framework/tests/relations_pk.py
+++ b/rest_framework/tests/relations_pk.py
@@ -194,6 +194,13 @@ class PKForeignKeyTests(TestCase):
]
self.assertEquals(serializer.data, expected)
+ def test_foreign_key_update_incorrect_type(self):
+ data = {'id': 1, 'name': u'source-1', 'target': 'foo'}
+ instance = ForeignKeySource.objects.get(pk=1)
+ serializer = ForeignKeySourceSerializer(instance, data=data)
+ self.assertFalse(serializer.is_valid())
+ self.assertEquals(serializer.errors, {'target': [u'Incorrect type. Expected pk value, received str.']})
+
def test_reverse_foreign_key_update(self):
data = {'id': 2, 'name': u'target-2', 'sources': [1, 3]}
instance = ForeignKeyTarget.objects.get(pk=2)