Skip to content

Commit

Permalink
Fix a bug in images api when querying image in-queue by id
Browse files Browse the repository at this point in the history
  • Loading branch information
hv0905 committed Jul 9, 2024
1 parent 6468433 commit 0f242b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/Controllers/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ async def query_image_by_id(image_id: Annotated[UUID, Path(description="The id o
message="Success query the image with the given ID.")
except PointNotFoundError as ex:
if services.upload_service and image_id in services.upload_service.uploading_ids:
return QueryByIdApiResponse(img_status=ImageStatus.IN_QUEUE, message="The image is in the indexing queue.")
return QueryByIdApiResponse(img=None,
img_status=ImageStatus.IN_QUEUE,
message="The image is in the indexing queue.")
raise HTTPException(404, "Cannot find the image with the given ID.") from ex


Expand Down
5 changes: 5 additions & 0 deletions tests/api/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ def validate(hashes):
resp = upload(f)
assert resp.status_code == 409, i

# Query by ID
query = test_client.get(f'/images/id/{image_id}')
assert query.status_code == 200
assert query.json()['img_status'] == 'mapped' if i == 1 else 'in_queue'

# Validate
val_resp = validate(test_file_hashes)
assert val_resp.status_code == 200, i
Expand Down

0 comments on commit 0f242b1

Please sign in to comment.