mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
remove all but the 'read' nested serializer tests
This commit is contained in:
parent
8a41d4aa54
commit
c6a6d7ac15
|
@ -44,11 +44,6 @@ class ReverseForeignKeyTests(TestCase):
|
|||
self.new_target_data = {'id': 2, 'name': u'target-2', 'sources': []}
|
||||
self.data = [self.target_data, self.new_target_data]
|
||||
|
||||
def save_serialized_target(self, instance, data):
|
||||
serializer = ForeignKeyTargetSerializer(instance, data=data)
|
||||
self.assertTrue(serializer.is_valid())
|
||||
serializer.save()
|
||||
|
||||
def check_serialized_targets(self, data):
|
||||
queryset = ForeignKeyTarget.objects.all()
|
||||
serializer = ForeignKeyTargetSerializer(queryset)
|
||||
|
@ -56,38 +51,3 @@ class ReverseForeignKeyTests(TestCase):
|
|||
|
||||
def test_reverse_foreign_key_retrieve(self):
|
||||
self.check_serialized_targets(self.data)
|
||||
|
||||
def test_reverse_foreign_key_create(self):
|
||||
data = deepcopy(self.new_target_data)
|
||||
data['sources'].append({'name': u'source-4', 'target': 2})
|
||||
instance = ForeignKeyTarget.objects.get(pk=2)
|
||||
self.save_serialized_target(instance, data)
|
||||
|
||||
# Ensure target 2 has new source and everything else is as expected
|
||||
expected = deepcopy(self.data)
|
||||
expected[1]['sources'].append({'id': 4, 'name': 'source-4', 'target': 2})
|
||||
self.check_serialized_targets(expected)
|
||||
|
||||
def test_reverse_foreign_key_update(self):
|
||||
data = deepcopy(self.target_data)
|
||||
data['sources'][0]['name'] = 'source-1-changed'
|
||||
data['sources'][2]['name'] = 'source-3-changed'
|
||||
instance = ForeignKeyTarget.objects.get(pk=1)
|
||||
self.save_serialized_target(instance, data)
|
||||
|
||||
# Ensure target 1 is updated, and everything else is as expected
|
||||
expected = deepcopy(self.data)
|
||||
expected[0]['sources'][0]['name'] = 'source-1-changed'
|
||||
expected[0]['sources'][2]['name'] = 'source-3-changed'
|
||||
self.check_serialized_targets(expected)
|
||||
|
||||
def test_reverse_foreign_key_delete(self):
|
||||
data = deepcopy(self.target_data)
|
||||
del data['sources'][2]
|
||||
instance = ForeignKeyTarget.objects.get(pk=1)
|
||||
self.save_serialized_target(instance, data)
|
||||
|
||||
# Ensure target 1 has 2 sources and everything else is as expected
|
||||
expected = deepcopy(self.data)
|
||||
del expected[0]['sources'][2]
|
||||
self.check_serialized_targets(expected)
|
||||
|
|
Loading…
Reference in New Issue
Block a user