Ticket #17717: 17717-test.diff

File 17717-test.diff, 2.1 KB (added by Claude Paroz, 13 years ago)

Test showing bug

  • tests/regressiontests/serializers_regress/models.py

    diff --git a/tests/regressiontests/serializers_regress/models.py b/tests/regressiontests/serializers_regress/models.py
    index b3ae1fe..9381349 100644
    a b class ExplicitInheritBaseModel(BaseModel):  
    259259    parent = models.OneToOneField(BaseModel)
    260260    child_data = models.IntegerField()
    261261
     262class ProxyBaseModel(BaseModel):
     263    class Meta:
     264        proxy = True
     265
    262266class LengthModel(models.Model):
    263267    data = models.IntegerField()
    264268
  • tests/regressiontests/serializers_regress/tests.py

    diff --git a/tests/regressiontests/serializers_regress/tests.py b/tests/regressiontests/serializers_regress/tests.py
    index 5abff63..d8c5fab 100644
    a b from .models import (BooleanData, CharData, DateData, DateTimeData, EmailData,  
    4040    DecimalPKData, FloatPKData, IntegerPKData, IPAddressPKData,
    4141    GenericIPAddressPKData, PhonePKData, PositiveIntegerPKData,
    4242    PositiveSmallIntegerPKData, SlugPKData, SmallPKData, USStatePKData,
    43     AutoNowDateTimeData, ModifyingSaveData, InheritAbstractModel,
    44     ExplicitInheritBaseModel, InheritBaseModel, BigIntegerData, LengthModel,
    45     Tag, ComplexModel)
     43    AutoNowDateTimeData, ModifyingSaveData, InheritAbstractModel, BaseModel,
     44    ExplicitInheritBaseModel, InheritBaseModel, ProxyBaseModel, BigIntegerData,
     45    LengthModel, Tag, ComplexModel)
    4646
    4747# A set of functions that can be used to recreate
    4848# test data objects of various kinds.
    class SerializerTests(TestCase):  
    408408            for obj in serializers.deserialize("yaml", "{"):
    409409                pass
    410410
     411    def test_serialize_proxy_model(self):
     412        BaseModel.objects.create(parent_data=1)
     413        base_objects  = BaseModel.objects.all()
     414        proxy_objects = ProxyBaseModel.objects.all()
     415        base_data  = serializers.serialize("json", base_objects)
     416        proxy_data = serializers.serialize("json", proxy_objects)
     417        self.assertEqual(base_data, proxy_data.replace('proxy', ''))
     418
    411419
    412420def serializerTest(format, self):
    413421
Back to Top