mirror of
https://github.com/jazzband/django-eav2.git
synced 2026-04-25 01:14:43 +00:00
test(queryset): add filter test for multiple EAV attributes
This commit is contained in:
parent
b31f5c2d37
commit
dd5f375640
1 changed files with 21 additions and 0 deletions
|
|
@ -298,3 +298,24 @@ class Queries(TestCase):
|
|||
p = Patient.objects.get_or_create(name='Beth', example=e)[0]
|
||||
c = ExampleModel.objects.filter(patient=p)
|
||||
self.assertEqual(c.count(), 1)
|
||||
|
||||
def test_filter_with_multiple_eav_attributes(self):
|
||||
"""
|
||||
Test filtering a model using both regular and multiple EAV attributes.
|
||||
|
||||
This test initializes test data and then filters the Patient test model
|
||||
based on a combination of a regular attribute and multiple EAV attributes.
|
||||
"""
|
||||
self.init_data()
|
||||
|
||||
# Use the filter method with 3 EAV attribute conditions
|
||||
patients = Patient.objects.filter(
|
||||
name='Anne',
|
||||
eav__age=3,
|
||||
eav__illness='cold',
|
||||
eav__fever='no',
|
||||
)
|
||||
|
||||
# Assert that the expected patient is returned
|
||||
self.assertEqual(len(patients), 1)
|
||||
self.assertEqual(patients[0].name, 'Anne')
|
||||
|
|
|
|||
Loading…
Reference in a new issue