diff --git a/backend/src/agents/agent.py b/backend/src/agents/agent.py index d189f818..8f831062 100644 --- a/backend/src/agents/agent.py +++ b/backend/src/agents/agent.py @@ -1,7 +1,7 @@ from abc import ABC import json import logging -from typing import List, Type, TypeVar, Optional +from typing import List, Type, TypeVar from src.llm import LLM, get_llm from src.utils.log_publisher import LogPrefix, publish_log_info diff --git a/backend/src/agents/materiality_agent.py b/backend/src/agents/materiality_agent.py index c2feda39..dcb36d71 100644 --- a/backend/src/agents/materiality_agent.py +++ b/backend/src/agents/materiality_agent.py @@ -2,7 +2,6 @@ from pathlib import Path import logging -from src.agents import agent from src.llm import LLMFileFromPath from src.agents import Agent from src.prompts import PromptEngine diff --git a/backend/src/agents/report_agent.py b/backend/src/agents/report_agent.py index 3a5f550d..a2f911d2 100644 --- a/backend/src/agents/report_agent.py +++ b/backend/src/agents/report_agent.py @@ -1,7 +1,6 @@ import json import logging -from src.agents import agent from src.agents import Agent from src.prompts import PromptEngine diff --git a/backend/src/utils/file_utils.py b/backend/src/utils/file_utils.py index 45571e16..9931b60f 100644 --- a/backend/src/utils/file_utils.py +++ b/backend/src/utils/file_utils.py @@ -18,7 +18,7 @@ def handle_file_upload(file: UploadFile) -> FileUpload: raise HTTPException(status_code=413, detail=f"File upload must be less than {MAX_FILE_SIZE} bytes") if not file.filename: - raise HTTPException(status_code=400, detail=f"File upload must have a filename") + raise HTTPException(status_code=400, detail="Filename missing from file upload") if "application/pdf" == file.content_type: start_time = time.time() diff --git a/backend/tests/utils/file_utils_test.py b/backend/tests/utils/file_utils_test.py index 307dbcca..c4c32baa 100644 --- a/backend/tests/utils/file_utils_test.py +++ b/backend/tests/utils/file_utils_test.py @@ -7,8 +7,8 @@ from src.utils.file_utils import handle_file_upload -def test_handle_file_upload_size(): +def test_handle_file_upload_size(): with pytest.raises(HTTPException) as err: handle_file_upload(UploadFile(file=BinaryIO(), size=15*1024*1024)) @@ -17,16 +17,24 @@ def test_handle_file_upload_size(): def test_handle_file_upload_unsupported_type(): - headers = Headers({"content-type": "text/html"}) with pytest.raises(HTTPException) as err: - handle_file_upload(UploadFile(file=BinaryIO(), size=15*1024, headers=headers)) + handle_file_upload(UploadFile(file=BinaryIO(), size=15*1024, headers=headers, filename="test.txt")) assert err.value.status_code == 400 assert err.value.detail == 'File upload must be supported type (text/plain or application/pdf)' -def test_handle_file_upload_text(mocker): +def test_handle_file_upload_unsupported_type(): + headers = Headers({"content-type": "text/html"}) + with pytest.raises(HTTPException) as err: + handle_file_upload(UploadFile(file=BytesIO(b"test content"), size=12, headers=headers)) + + assert err.value.status_code == 400 + assert err.value.detail == 'Filename missing from file upload' + + +def test_handle_file_upload_text(mocker): mock = mocker.patch("src.utils.file_utils.update_session_file_uploads", MagicMock()) headers = Headers({"content-type": "text/plain"}) @@ -37,7 +45,6 @@ def test_handle_file_upload_text(mocker): def test_handle_file_upload_pdf(mocker): - mock = mocker.patch("src.utils.file_utils.update_session_file_uploads", MagicMock()) pdf_mock = mocker.patch("src.utils.file_utils.PdfReader", MagicMock())