  
      def test_one_to_one_update(self):
          data = {'id': 3, 'name': 'target-3-updated', 'target_source': {'id': 3, 'name': 'target-source-3-updated', 'source': {'id': 3, 'name': 'source-3-updated'}}}
          instance = OneToOneTarget.objects.get(pk=3)
          serializer = OneToOneTargetSerializer(instance, data=data)
          self.assertTrue(serializer.is_valid())
          obj = serializer.save()
          self.assertEqual(serializer.data, data)
          self.assertEqual(obj.name, 'target-3-updated')
  
 
</s> remove         data = {'id': 3, 'name': 'target-3-updated', 'target_source': {'id': 3, 'name': 'target-source-3-updated', 'source': {'id': 3, 'name': 'source-3-updated'}}}
 </s> add         data = {'id': 3, 'name': 'target-3-updated', 'source': {'id': 3, 'name': 'source-3-updated'}} </s> remove         # Ensure (target_source 3, source 3) are deleted,
 </s> add     def test_one_to_one_create_with_invalid_data(self):
        data = {'id': 4, 'name': 'source-4', 'target': {'id': 4}}
        serializer = self.Serializer(data=data)
        self.assertFalse(serializer.is_valid())
        self.assertEqual(serializer.errors, {'target': [{'name': ['This field is required.']}]})

    def test_one_to_one_update(self):
        data = {'id': 3, 'name': 'source-3-updated', 'target': {'id': 3, 'name': 'target-3-updated'}}
        instance = OneToOneSource.objects.get(pk=3)
        serializer = self.Serializer(instance, data=data)
        self.assertTrue(serializer.is_valid())
        obj = serializer.save()
        self.assertEqual(serializer.data, data)
        self.assertEqual(obj.name, 'source-3-updated')

        # Ensure (target 3, target_source 3, source 3) are updated, </s> remove         self.assertEqual(serializer.errors, {'target_source': [{'source': [{'name': ['This field is required.']}]}]})
 </s> add         self.assertEqual(serializer.errors, {'source': [{'name': ['This field is required.']}]}) </s> remove         serializer.save()
 </s> add         obj = serializer.save()
        self.assertEqual(serializer.data, data)
        self.assertEqual(obj.name, 'source-4')

        # Ensure (target 4, target_source 4, source 4) are added, and
        # everything else is as expected.
        queryset = OneToOneSource.objects.all()
        serializer = self.Serializer(queryset)
        expected = [
            {'id': 1, 'name': 'source-1', 'target': {'id': 1, 'name': 'target-1'}},
            {'id': 2, 'name': 'source-2', 'target': {'id': 2, 'name': 'target-2'}},
            {'id': 3, 'name': 'source-3', 'target': {'id': 3, 'name': 'target-3'}},
            {'id': 4, 'name': 'source-4', 'target': {'id': 4, 'name': 'target-4'}}
        ]
        self.assertEqual(serializer.data, expected) </s> remove         data = {'id': 4, 'name': 'target-4', 'target_source': {'id': 4, 'name': 'target-source-4', 'source': {'id': 4, 'name': 'source-4'}}}
        serializer = OneToOneTargetSerializer(data=data)
 </s> add         data = {'id': 4, 'name': 'target-4', 'source': {'id': 4, 'name': 'source-4'}}
        serializer = self.Serializer(data=data)
        serializer = self.Serializer(instance, data=data)
  
      def test_one_to_one_update(self):
          data = {'id': 3, 'name': 'target-3-updated', 'target_source': {'id': 3, 'name': 'target-source-3-updated', 'source': {'id': 3, 'name': 'source-3-updated'}}}
          instance = OneToOneTarget.objects.get(pk=3)
        serializer = self.Serializer(instance, data=data)
          self.assertTrue(serializer.is_valid())
          obj = serializer.save()
          self.assertEqual(serializer.data, data)
          self.assertEqual(obj.name, 'target-3-updated')
  
keep keep keep keep replace keep keep keep keep keep
 Cleanup one-one nested tests and implementation 
rest_framework/tests/relations_nested.py