          queryset = ForeignKeyTarget.objects.all()
          serializer = ForeignKeyTargetSerializer(queryset)
          expected = deepcopy(self.data)
          expected[1]['sources'].append({'id': 4, 'name': 'source-4', 'target': 2})
          self.assertEquals(serializer.data, 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'
 
</s> remove         queryset = ForeignKeyTarget.objects.all()
        serializer = ForeignKeyTargetSerializer(queryset)
 </s> add  </s> remove         serializer = ForeignKeyTargetSerializer(instance, data=data)
        self.assertTrue(serializer.is_valid())
        self.assertEquals(serializer.data, data)
        serializer.save()
 </s> add         self.save_serialized_target(instance, data) </s> remove         self.assertEquals(serializer.data, expected)
 </s> add         self.check_serialized_targets(expected) </s> remove         queryset = ForeignKeyTarget.objects.all()
        serializer = ForeignKeyTargetSerializer(queryset)
 </s> add  </s> remove         self.assertEquals(serializer.data, self.data)
 </s> add         self.assertEquals(serializer.data, data)

    def test_reverse_foreign_key_retrieve(self):
        self.check_serialized_targets(self.data)
        self.check_serialized_targets(expected)
          queryset = ForeignKeyTarget.objects.all()
          serializer = ForeignKeyTargetSerializer(queryset)
          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'
keep keep keep keep replace keep keep keep keep keep
 Add two functions for more DRY reverse fk tests 
rest_framework/tests/nested_relations.py