Skip to content

Fix typo in test_embedded_model_array.py variable name #346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions tests/model_fields_/test_embedded_model_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def setUpTestData(cls):
),
],
)
cls.new_descoveries = Exhibit.objects.create(
cls.new_discoveries = Exhibit.objects.create(
name="New Discoveries",
sections=[
Section(
Expand Down Expand Up @@ -175,7 +175,7 @@ def test_nested_array_index(self):

def test_array_slice(self):
self.assertSequenceEqual(
Exhibit.objects.filter(sections__0_1__number=2), [self.new_descoveries]
Exhibit.objects.filter(sections__0_1__number=2), [self.new_discoveries]
)

def test_filter_unsupported_lookups_in_json(self):
Expand All @@ -190,7 +190,7 @@ def test_len(self):
self.assertCountEqual(Exhibit.objects.filter(sections__len=10), [])
self.assertCountEqual(
Exhibit.objects.filter(sections__len=1),
[self.egypt, self.new_descoveries],
[self.egypt, self.new_discoveries],
)
# Nested EMF
self.assertCountEqual(
Expand All @@ -210,26 +210,26 @@ def test_in(self):
)
self.assertCountEqual(
Exhibit.objects.filter(sections__number__in=[2]),
[self.new_descoveries, self.wonders],
[self.new_discoveries, self.wonders],
)
self.assertCountEqual(Exhibit.objects.filter(sections__number__in=[3]), [])

def test_iexact(self):
self.assertCountEqual(
Exhibit.objects.filter(sections__artifacts__0__name__iexact="lightHOuse of aLexandriA"),
[self.new_descoveries, self.wonders],
[self.new_discoveries, self.wonders],
)

def test_gt(self):
self.assertCountEqual(
Exhibit.objects.filter(sections__number__gt=1),
[self.new_descoveries, self.wonders],
[self.new_discoveries, self.wonders],
)

def test_gte(self):
self.assertCountEqual(
Exhibit.objects.filter(sections__number__gte=1),
[self.egypt, self.new_descoveries, self.wonders],
[self.egypt, self.new_discoveries, self.wonders],
)

def test_lt(self):
Expand All @@ -240,7 +240,7 @@ def test_lt(self):
def test_lte(self):
self.assertCountEqual(
Exhibit.objects.filter(sections__number__lte=2),
[self.egypt, self.wonders, self.new_descoveries],
[self.egypt, self.wonders, self.new_discoveries],
)

def test_querying_array_not_allowed(self):
Expand Down Expand Up @@ -296,11 +296,11 @@ def test_subquery_numeric_lookups(self):
section_number__in=models.OuterRef("sections__number")
).values("section_number")[:1]
tests = [
("exact", [self.egypt, self.new_descoveries, self.wonders]),
("exact", [self.egypt, self.new_discoveries, self.wonders]),
("lt", []),
("lte", [self.egypt, self.new_descoveries, self.wonders]),
("lte", [self.egypt, self.new_discoveries, self.wonders]),
("gt", [self.wonders]),
("gte", [self.egypt, self.new_descoveries, self.wonders]),
("gte", [self.egypt, self.new_discoveries, self.wonders]),
]
for lookup, expected in tests:
with self.subTest(lookup=lookup):
Expand All @@ -310,28 +310,28 @@ def test_subquery_numeric_lookups(self):
def test_subquery_in_lookup(self):
subquery = Audit.objects.filter(reviewed=True).values_list("section_number", flat=True)
result = Exhibit.objects.filter(sections__number__in=subquery)
self.assertCountEqual(result, [self.wonders, self.new_descoveries, self.egypt])
self.assertCountEqual(result, [self.wonders, self.new_discoveries, self.egypt])

def test_array_as_rhs(self):
result = Exhibit.objects.filter(main_section__number__in=models.F("sections__number"))
self.assertCountEqual(result, [self.new_descoveries])
self.assertCountEqual(result, [self.new_discoveries])

def test_array_annotation_lookup(self):
result = Exhibit.objects.annotate(section_numbers=models.F("main_section__number")).filter(
section_numbers__in=models.F("sections__number")
)
self.assertCountEqual(result, [self.new_descoveries])
self.assertCountEqual(result, [self.new_discoveries])

def test_array_as_rhs_for_arrayfield_lookups(self):
tests = [
("exact", [self.wonders]),
("lt", [self.new_descoveries]),
("lte", [self.wonders, self.new_descoveries]),
("lt", [self.new_discoveries]),
("lte", [self.wonders, self.new_discoveries]),
("gt", [self.egypt, self.lost_empires]),
("gte", [self.egypt, self.wonders, self.lost_empires]),
("overlap", [self.egypt, self.wonders, self.new_descoveries]),
("overlap", [self.egypt, self.wonders, self.new_discoveries]),
("contained_by", [self.wonders]),
("contains", [self.egypt, self.wonders, self.new_descoveries, self.lost_empires]),
("contains", [self.egypt, self.wonders, self.new_discoveries, self.lost_empires]),
]
for lookup, expected in tests:
with self.subTest(lookup=lookup):
Expand All @@ -350,7 +350,7 @@ def test_array_annotation_index(self):
result = Exhibit.objects.annotate(section_numbers=models.F("sections__number")).filter(
section_numbers__0=1
)
self.assertCountEqual(result, [self.new_descoveries, self.egypt])
self.assertCountEqual(result, [self.new_discoveries, self.egypt])

def test_array_annotation(self):
qs = Exhibit.objects.annotate(section_numbers=models.F("sections__number")).order_by("name")
Expand Down