Skip to content

Commit 07586da

Browse files
committed
Rename field in PolymorphicEmbeddedModelField test models
1 parent daa9a8e commit 07586da

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

tests/model_fields_/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class Dog(EmbeddedModel):
239239
barks = models.BooleanField(default=True)
240240
created_at = models.DateTimeField(auto_now_add=True)
241241
updated_at = models.DateTimeField(auto_now=True)
242-
toys = PolymorphicEmbeddedModelField(["Bone"], blank=True, null=True)
242+
favorite_toy = PolymorphicEmbeddedModelField(["Bone"], blank=True, null=True)
243243

244244
def __str__(self):
245245
return self.name
@@ -249,7 +249,7 @@ class Cat(EmbeddedModel):
249249
name = models.CharField(max_length=100)
250250
purs = models.BooleanField(default=True)
251251
weight = models.DecimalField(max_digits=4, decimal_places=2, blank=True, null=True)
252-
toys = PolymorphicEmbeddedModelField(["Mouse"], blank=True, null=True)
252+
favorite_toy = PolymorphicEmbeddedModelField(["Mouse"], blank=True, null=True)
253253

254254
def __str__(self):
255255
return self.name

tests/model_fields_/test_polymorphic_embedded_model.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def setUpTestData(cls):
9999
pet=Cat(
100100
name=f"Cat {x}",
101101
weight=f"{x}.5",
102-
toys=Mouse(manufacturer=f"Maker {x}"),
102+
favorite_toy=Mouse(manufacturer=f"Maker {x}"),
103103
),
104104
)
105105
for x in range(6)
@@ -110,7 +110,7 @@ def setUpTestData(cls):
110110
pet=Dog(
111111
name=f"Dog {x}",
112112
barks=x % 2 == 0,
113-
toys=Bone(brand=f"Brand {x}"),
113+
favorite_toy=Bone(brand=f"Brand {x}"),
114114
),
115115
)
116116
for x in range(6)
@@ -147,17 +147,17 @@ def test_boolean(self):
147147
)
148148

149149
def test_nested(self):
150-
# Cat and Dog both have field toys = PolymorphicEmbeddedModelField(...)
150+
# Cat and Dog both have favorite_toy = PolymorphicEmbeddedModelField(...)
151151
# but with different models. It's possible to query the fields of the
152-
# Dog's toys because it's the first model in Person.pet.
152+
# Dog's favorite_toy because it's the first model in Person.pet.
153153
self.assertCountEqual(
154-
Person.objects.filter(pet__toys__brand="Brand 1"),
154+
Person.objects.filter(pet__favorite_toy__brand="Brand 1"),
155155
[self.dog_owners[1]],
156156
)
157157
# The fields of Cat can't be queried.
158-
msg = "The models of field 'toys' have no field named 'manufacturer'."
158+
msg = "The models of field 'favorite_toy' have no field named 'manufacturer'."
159159
with self.assertRaisesMessage(FieldDoesNotExist, msg):
160-
(Person.objects.filter(pet__toys__manufacturer="Maker 1"),)
160+
(Person.objects.filter(pet__favorite_toy__manufacturer="Maker 1"),)
161161

162162

163163
class InvalidLookupTests(SimpleTestCase):

0 commit comments

Comments
 (0)