Skip to content

Commit 65024dd

Browse files
committed
Move test to simplify diff
1 parent 4e85fc1 commit 65024dd

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

tests/model_fields_/test_embedded_model.py

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -102,56 +102,6 @@ def test_pre_save(self):
102102
self.assertGreater(obj.data.auto_now, auto_now_two)
103103

104104

105-
class ArrayFieldTests(TestCase):
106-
@classmethod
107-
def setUpTestData(cls):
108-
cls.book = Book.objects.create(
109-
author=Author(
110-
name="Shakespeare",
111-
age=55,
112-
skills=["writing", "editing"],
113-
address=Address(city="NYC", state="NY", tags=["home", "shipping"]),
114-
),
115-
)
116-
117-
def test_contains(self):
118-
self.assertCountEqual(Book.objects.filter(author__skills__contains=["nonexistent"]), [])
119-
self.assertCountEqual(
120-
Book.objects.filter(author__skills__contains=["writing"]), [self.book]
121-
)
122-
# Nested
123-
self.assertCountEqual(
124-
Book.objects.filter(author__address__tags__contains=["nonexistent"]), []
125-
)
126-
self.assertCountEqual(
127-
Book.objects.filter(author__address__tags__contains=["home"]), [self.book]
128-
)
129-
130-
def test_contained_by(self):
131-
self.assertCountEqual(
132-
Book.objects.filter(author__skills__contained_by=["writing", "publishing"]), []
133-
)
134-
self.assertCountEqual(
135-
Book.objects.filter(author__skills__contained_by=["writing", "editing", "publishing"]),
136-
[self.book],
137-
)
138-
# Nested
139-
self.assertCountEqual(
140-
Book.objects.filter(author__address__tags__contained_by=["home", "work"]), []
141-
)
142-
self.assertCountEqual(
143-
Book.objects.filter(author__address__tags__contained_by=["home", "work", "shipping"]),
144-
[self.book],
145-
)
146-
147-
def test_len(self):
148-
self.assertCountEqual(Book.objects.filter(author__skills__len=1), [])
149-
self.assertCountEqual(Book.objects.filter(author__skills__len=2), [self.book])
150-
# Nested
151-
self.assertCountEqual(Book.objects.filter(author__address__tags__len=1), [])
152-
self.assertCountEqual(Book.objects.filter(author__address__tags__len=2), [self.book])
153-
154-
155105
class EmbeddedArrayTests(TestCase):
156106
def test_save_load(self):
157107
reviews = [
@@ -424,6 +374,56 @@ def test_nested(self):
424374
self.assertCountEqual(Book.objects.filter(author__address__city="NYC"), [obj])
425375

426376

377+
class ArrayFieldTests(TestCase):
378+
@classmethod
379+
def setUpTestData(cls):
380+
cls.book = Book.objects.create(
381+
author=Author(
382+
name="Shakespeare",
383+
age=55,
384+
skills=["writing", "editing"],
385+
address=Address(city="NYC", state="NY", tags=["home", "shipping"]),
386+
),
387+
)
388+
389+
def test_contains(self):
390+
self.assertCountEqual(Book.objects.filter(author__skills__contains=["nonexistent"]), [])
391+
self.assertCountEqual(
392+
Book.objects.filter(author__skills__contains=["writing"]), [self.book]
393+
)
394+
# Nested
395+
self.assertCountEqual(
396+
Book.objects.filter(author__address__tags__contains=["nonexistent"]), []
397+
)
398+
self.assertCountEqual(
399+
Book.objects.filter(author__address__tags__contains=["home"]), [self.book]
400+
)
401+
402+
def test_contained_by(self):
403+
self.assertCountEqual(
404+
Book.objects.filter(author__skills__contained_by=["writing", "publishing"]), []
405+
)
406+
self.assertCountEqual(
407+
Book.objects.filter(author__skills__contained_by=["writing", "editing", "publishing"]),
408+
[self.book],
409+
)
410+
# Nested
411+
self.assertCountEqual(
412+
Book.objects.filter(author__address__tags__contained_by=["home", "work"]), []
413+
)
414+
self.assertCountEqual(
415+
Book.objects.filter(author__address__tags__contained_by=["home", "work", "shipping"]),
416+
[self.book],
417+
)
418+
419+
def test_len(self):
420+
self.assertCountEqual(Book.objects.filter(author__skills__len=1), [])
421+
self.assertCountEqual(Book.objects.filter(author__skills__len=2), [self.book])
422+
# Nested
423+
self.assertCountEqual(Book.objects.filter(author__address__tags__len=1), [])
424+
self.assertCountEqual(Book.objects.filter(author__address__tags__len=2), [self.book])
425+
426+
427427
class InvalidLookupTests(SimpleTestCase):
428428
def test_invalid_field(self):
429429
msg = "Author has no field named 'first_name'"

0 commit comments

Comments
 (0)