From 04119245ec5dc80f7376e319e5876b9fb6711c45 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 21 Dec 2012 09:15:28 +0000 Subject: [PATCH] Make nested tests consistent with pk and hyperlink tests --- rest_framework/tests/relations_nested.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/rest_framework/tests/relations_nested.py b/rest_framework/tests/relations_nested.py index 0d18d4adc..3482c2522 100644 --- a/rest_framework/tests/relations_nested.py +++ b/rest_framework/tests/relations_nested.py @@ -35,18 +35,17 @@ class ReverseForeignKeyTests(TestCase): for idx in range(1, 4): source = ForeignKeySource(name='source-%d' % idx, target=target) source.save() - self.target_data = {'id': 1, 'name': u'target-1', 'sources': [ + + def test_reverse_foreign_key_retrieve(self): + queryset = ForeignKeyTarget.objects.all() + serializer = ForeignKeyTargetSerializer(queryset) + expected = [ + {'id': 1, 'name': u'target-1', 'sources': [ {'id': 1, 'name': u'source-1', 'target': 1}, {'id': 2, 'name': u'source-2', 'target': 1}, {'id': 3, 'name': u'source-3', 'target': 1}, + ]}, + {'id': 2, 'name': u'target-2', 'sources': [ ]} - self.new_target_data = {'id': 2, 'name': u'target-2', 'sources': []} - self.data = [self.target_data, self.new_target_data] - - def check_serialized_targets(self, data): - queryset = ForeignKeyTarget.objects.all() - serializer = ForeignKeyTargetSerializer(queryset) - self.assertEquals(serializer.data, data) - - def test_reverse_foreign_key_retrieve(self): - self.check_serialized_targets(self.data) + ] + self.assertEquals(serializer.data, expected)