Compare commits

..

2 Commits

Author SHA1 Message Date
Emma Foster
a4940bfd1c
Merge 3f8989968e into cb54c9829d 2024-10-31 17:37:22 +00:00
emmalynf
3f8989968e Update slug service to return empty list and corresponding tests 2024-10-31 13:36:41 -04:00
2 changed files with 7 additions and 7 deletions

View File

@ -155,6 +155,6 @@ class ResourceService:
entities = self._session.scalars(query).all() entities = self._session.scalars(query).all()
if not entities: if not entities:
raise ResourceNotFoundException(f"No resource found with matching slug: {search_string}") return []
return [entity.to_model() for entity in entities] return [entity.to_model() for entity in entities]

View File

@ -106,14 +106,14 @@ def test_get_by_slug(resource_svc: ResourceService):
def test_get_by_slug_not_found(resource_svc: ResourceService): def test_get_by_slug_not_found(resource_svc: ResourceService):
""" Test getting a resource that does not exist """ """ Test getting a resource that does not exist """
slug = "Not Found" slug = "Not Found"
with pytest.raises(ResourceNotFoundException):
resources = resource_svc.get_by_slug(user_test_data.admin, slug) resources = resource_svc.get_by_slug(user_test_data.admin, slug)
pytest.fail() assert len(resources) == 0
assert resources == []
def test_get_by_slug_no_permission(resource_svc: ResourceService): def test_get_by_slug_no_permission(resource_svc: ResourceService):
""" Test getting a resource the user does not have access to """ """ Test getting a resource the user does not have access to """
slug = "Resource 2" slug = "Resource 2"
with pytest.raises(ResourceNotFoundException):
resources = resource_svc.get_by_slug(user_test_data.employee, slug) resources = resource_svc.get_by_slug(user_test_data.employee, slug)
pytest.fail() assert len(resources) == 0
assert resources == []