Code

Ticket #17717: 17717-test.diff

File 17717-test.diff, 2.1 KB (added by claudep, 2 years ago)

Test showing bug

Line 
1diff --git a/tests/regressiontests/serializers_regress/models.py b/tests/regressiontests/serializers_regress/models.py
2index b3ae1fe..9381349 100644
3--- a/tests/regressiontests/serializers_regress/models.py
4+++ b/tests/regressiontests/serializers_regress/models.py
5@@ -259,6 +259,10 @@ class ExplicitInheritBaseModel(BaseModel):
6     parent = models.OneToOneField(BaseModel)
7     child_data = models.IntegerField()
8 
9+class ProxyBaseModel(BaseModel):
10+    class Meta:
11+        proxy = True
12+
13 class LengthModel(models.Model):
14     data = models.IntegerField()
15 
16diff --git a/tests/regressiontests/serializers_regress/tests.py b/tests/regressiontests/serializers_regress/tests.py
17index 5abff63..d8c5fab 100644
18--- a/tests/regressiontests/serializers_regress/tests.py
19+++ b/tests/regressiontests/serializers_regress/tests.py
20@@ -40,9 +40,9 @@ from .models import (BooleanData, CharData, DateData, DateTimeData, EmailData,
21     DecimalPKData, FloatPKData, IntegerPKData, IPAddressPKData,
22     GenericIPAddressPKData, PhonePKData, PositiveIntegerPKData,
23     PositiveSmallIntegerPKData, SlugPKData, SmallPKData, USStatePKData,
24-    AutoNowDateTimeData, ModifyingSaveData, InheritAbstractModel,
25-    ExplicitInheritBaseModel, InheritBaseModel, BigIntegerData, LengthModel,
26-    Tag, ComplexModel)
27+    AutoNowDateTimeData, ModifyingSaveData, InheritAbstractModel, BaseModel,
28+    ExplicitInheritBaseModel, InheritBaseModel, ProxyBaseModel, BigIntegerData,
29+    LengthModel, Tag, ComplexModel)
30 
31 # A set of functions that can be used to recreate
32 # test data objects of various kinds.
33@@ -408,6 +408,14 @@ class SerializerTests(TestCase):
34             for obj in serializers.deserialize("yaml", "{"):
35                 pass
36 
37+    def test_serialize_proxy_model(self):
38+        BaseModel.objects.create(parent_data=1)
39+        base_objects  = BaseModel.objects.all()
40+        proxy_objects = ProxyBaseModel.objects.all()
41+        base_data  = serializers.serialize("json", base_objects)
42+        proxy_data = serializers.serialize("json", proxy_objects)
43+        self.assertEqual(base_data, proxy_data.replace('proxy', ''))
44+
45 
46 def serializerTest(format, self):
47