Skip to content

Commit

Permalink
Fix tag casing match in new tag view (#3688)
Browse files Browse the repository at this point in the history
* Remove tag.lower() from search view

Signed-off-by: Olga Bulat <obulat@gmail.com>

* Add a test for upper case tag

Signed-off-by: Olga Bulat <obulat@gmail.com>

---------

Signed-off-by: Olga Bulat <obulat@gmail.com>
  • Loading branch information
obulat authored Feb 4, 2024
1 parent 826f30b commit 8a939a4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
3 changes: 1 addition & 2 deletions api/api/views/media_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ def collection(self, request, tag, source, creator, *_, **__):

@action(detail=False, methods=["get"], url_path="tag/(?P<tag>[^/.]+)")
def tag_collection(self, request, tag, *_, **__):
tag_lower = tag.lower()
return self.collection(request, tag_lower, None, None)
return self.collection(request, tag, None, None)

@action(detail=False, methods=["get"], url_path="source/(?P<source>[^/.]+)")
def source_collection(self, request, source, *_, **__):
Expand Down
6 changes: 3 additions & 3 deletions api/test/media_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ def search_by_category(media_path, category, fixture):
assert all(audio_item["category"] == category for audio_item in results)


def tag_collection(media_path):
response = requests.get(f"{API_URL}/v1/{media_path}/tag/cat")
def tag_collection(media_path, tag="cat"):
response = requests.get(f"{API_URL}/v1/{media_path}/tag/{tag}")
assert response.status_code == 200

results = response.json()["results"]
for r in results:
tag_names = [tag["name"] for tag in r["tags"]]
assert "cat" in tag_names
assert tag in tag_names


def source_collection(media_path):
Expand Down
6 changes: 5 additions & 1 deletion api/test/test_image_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ def test_image_uuid_validation():


def test_image_tag_collection():
tag_collection("images")
tag_collection("images", "cat")


def test_image_tag_collection_case_sensitive():
tag_collection("images", "Cat")


def test_image_source_collection():
Expand Down
Loading

0 comments on commit 8a939a4

Please sign in to comment.