diff --git a/openedx_tagging/core/tagging/rest_api/v1/views.py b/openedx_tagging/core/tagging/rest_api/v1/views.py index 743f5bcd2..63754d38f 100644 --- a/openedx_tagging/core/tagging/rest_api/v1/views.py +++ b/openedx_tagging/core/tagging/rest_api/v1/views.py @@ -166,6 +166,7 @@ class TaxonomyView(ModelViewSet): """ + lookup_value_regex = r"\d+" serializer_class = TaxonomySerializer permission_classes = [TaxonomyObjectPermissions] diff --git a/tests/openedx_tagging/core/tagging/test_views.py b/tests/openedx_tagging/core/tagging/test_views.py index d97296ba0..07816eed4 100644 --- a/tests/openedx_tagging/core/tagging/test_views.py +++ b/tests/openedx_tagging/core/tagging/test_views.py @@ -195,6 +195,13 @@ def test_detail_taxonomy_404(self) -> None: response = self.client.get(url) assert response.status_code == status.HTTP_404_NOT_FOUND + def test_detail_taxonomy_invalud_pk(self) -> None: + url = TAXONOMY_DETAIL_URL.format(pk="invalid") + + self.client.force_authenticate(user=self.staff) + response = self.client.get(url) + assert response.status_code == status.HTTP_404_NOT_FOUND + @ddt.data( (None, status.HTTP_401_UNAUTHORIZED), ("user", status.HTTP_403_FORBIDDEN),