Skip to content

Commit

Permalink
🧪 [#472] add regression tests if filter with icontains have value wit…
Browse files Browse the repository at this point in the history
…h comma
  • Loading branch information
annashamray committed Dec 9, 2024
1 parent 259c9a6 commit 5b56087
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/objects/tests/v2/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,63 @@ def test_filter_icontains_numeric(self):
f"http://testserver{reverse('object-detail', args=[record.object.uuid])}",
)

def test_filter_icontains_string_with_comma(self):
"""
regression test for https://github.com/maykinmedia/objects-api/issues/472
"""
record = ObjectRecordFactory.create(
data={"name": "Something important"}, object__object_type=self.object_type
)
ObjectRecordFactory.create(
data={"name": "Advies, support en kennis om te weten"},
object__object_type=self.object_type,
)
ObjectRecordFactory.create(data={}, object__object_type=self.object_type)

response = self.client.get(
self.url, {"data_attrs": "name__icontains__Advies, support en kennis"}
)

self.assertEqual(response.status_code, status.HTTP_200_OK)

data = response.json()["results"]

self.assertEqual(len(data), 1)
self.assertEqual(
data[0]["url"],
f"http://testserver{reverse('object-detail', args=[record.object.uuid])}",
)

def test_filter_two_icontains_with_comma(self):
"""
regression test for https://github.com/maykinmedia/objects-api/issues/472
"""
record = ObjectRecordFactory.create(
data={"name": "Something important"}, object__object_type=self.object_type
)
ObjectRecordFactory.create(
data={"name": "Advies, support en kennis om te weten"},
object__object_type=self.object_type,
)
ObjectRecordFactory.create(data={}, object__object_type=self.object_type)

response = self.client.get(
self.url,
{
"data_attrs": "name__icontains__Advies, support en kennis,name__icontains__om"
},
)

self.assertEqual(response.status_code, status.HTTP_200_OK)

data = response.json()["results"]

self.assertEqual(len(data), 1)
self.assertEqual(
data[0]["url"],
f"http://testserver{reverse('object-detail', args=[record.object.uuid])}",
)

def test_filter_exclude_old_records(self):
record_old = ObjectRecordFactory.create(
data={"diameter": 45},
Expand Down

0 comments on commit 5b56087

Please sign in to comment.