diff --git a/src/api_service/api/routers/summarize.py b/src/api_service/api/routers/summarize.py index 1c009f64..72b5e83b 100644 --- a/src/api_service/api/routers/summarize.py +++ b/src/api_service/api/routers/summarize.py @@ -14,7 +14,7 @@ # In-memory storage for extracted issues parsed_issues_storage = {"issues": []} -@router.post("/summarize/process-pdf/") +@router.post("/process-pdf/") async def process_pdf( pdf_file: UploadFile = File(...), project_id: str = "473358048261", @@ -58,7 +58,7 @@ async def process_pdf( raise HTTPException(status_code=500, detail=f"Error processing file: {str(e)}") -@router.post("/summarize/get-grade/") +@router.post("/get-grade/") async def get_grade(): """ Grade the parsed privacy issues. diff --git a/src/models/tests/integration/test_api_endpoints.py b/src/models/tests/integration/test_api_endpoints.py index eea70f41..cdf4e02c 100644 --- a/src/models/tests/integration/test_api_endpoints.py +++ b/src/models/tests/integration/test_api_endpoints.py @@ -41,7 +41,7 @@ def test_process_pdf_endpoint(mock_post): # Simulate a file upload files = {"pdf_file": ("mock.pdf", b"PDF content", "application/pdf")} - response = httpx.post(f"{BASE_URL}/summarize/process-pdf", files=files) + response = httpx.post(f"{BASE_URL}/process-pdf/", files=files) # Assertions assert response.status_code == 200 @@ -57,7 +57,7 @@ def test_get_grade_endpoint(mock_post): mock_response.json.return_value = {"grade": "A"} mock_post.return_value = mock_response - response = httpx.post(f"{BASE_URL}/summarize/get-grade", json={"input": "test data"}) + response = httpx.post(f"{BASE_URL}/get-grade/", json={"input": "test data"}) assert response.status_code == 200 assert response.json() == {"grade": "A"} @@ -91,7 +91,7 @@ def test_get_grade_invalid_payload(mock_post): mock_response.json.return_value = {"error": "Invalid data format"} mock_post.return_value = mock_response - response = httpx.post(f"{BASE_URL}/summarize/get-grade", json={"invalid": "data"}) + response = httpx.post(f"{BASE_URL}/get-grade/", json={"invalid": "data"}) assert response.status_code == 422 assert response.json() == {"error": "Invalid data format"} @@ -103,7 +103,7 @@ def test_get_grade_invalid_payload(mock_post): mock_response.json.return_value = {"error": "Invalid data format"} mock_post.return_value = mock_response - response = httpx.post(f"{BASE_URL}/summarize/get-grade", json={"invalid": "data"}) + response = httpx.post(f"{BASE_URL}/get-grade/", json={"invalid": "data"}) assert response.status_code == 422 assert response.json() == {"error": "Invalid data format"} @@ -116,7 +116,7 @@ def test_process_pdf_invalid_file(mock_post): mock_post.return_value = mock_response files = {"pdf_file": ("invalid.txt", b"Text content", "text/plain")} - response = httpx.post(f"{BASE_URL}/summarize/process-pdf", files=files) + response = httpx.post(f"{BASE_URL}/process-pdf/", files=files) assert response.status_code == 400 assert response.json() == {"error": "Invalid file type"} @@ -169,7 +169,7 @@ def test_process_pdf_invalid_project_id(mock_post): files = {"pdf_file": ("mock.pdf", b"PDF content", "application/pdf")} response = httpx.post( - f"{BASE_URL}/summarize/process-pdf", + f"{BASE_URL}/process-pdf/", files=files, data={"project_id": "invalid_project", "location_id": "us-central1", "endpoint_id": "3504346967373250560"} ) @@ -186,7 +186,7 @@ def test_process_pdf_empty_file(mock_post): mock_post.return_value = mock_response files = {"pdf_file": ("empty.pdf", b"", "application/pdf")} - response = httpx.post(f"{BASE_URL}/summarize/process-pdf", files=files) + response = httpx.post(f"{BASE_URL}/process-pdf/", files=files) assert response.status_code == 400 assert response.json() == {"detail": "A valid PDF file is required."} @@ -201,7 +201,7 @@ def test_get_grade_missing_issues(mock_post): } mock_post.return_value = mock_response - response = httpx.post(f"{BASE_URL}/summarize/get-grade") + response = httpx.post(f"{BASE_URL}/get-grade/") assert response.status_code == 400 assert response.json() == { "detail": "No issues have been processed yet. Please process a PDF first." @@ -215,7 +215,7 @@ def test_get_grade_invalid_grading_logic(mock_post): mock_response.json.return_value = {"detail": "Error grading issues: Invalid data"} mock_post.return_value = mock_response - response = httpx.post(f"{BASE_URL}/summarize/get-grade") + response = httpx.post(f"{BASE_URL}/get-grade/") assert response.status_code == 500 assert response.json() == {"detail": "Error grading issues: Invalid data"} @@ -276,7 +276,7 @@ def test_process_pdf_processing_error(mock_post): mock_post.return_value = mock_response files = {"pdf_file": ("mock.pdf", b"PDF content", "application/pdf")} - response = httpx.post(f"{BASE_URL}/summarize/process-pdf", files=files) + response = httpx.post(f"{BASE_URL}/process-pdf/", files=files) assert response.status_code == 500 assert response.json() == {"detail": "Error processing file: Unexpected error"} @@ -289,7 +289,7 @@ def test_process_pdf_invalid_extension(mock_post): mock_post.return_value = mock_response files = {"pdf_file": ("invalid.txt", b"Not a PDF", "text/plain")} - response = httpx.post(f"{BASE_URL}/summarize/process-pdf", files=files) + response = httpx.post(f"{BASE_URL}/process-pdf/", files=files) assert response.status_code == 400 assert response.json() == {"detail": "A valid PDF file is required."} @@ -302,7 +302,7 @@ def test_process_pdf_no_file(mock_post): mock_response.json.return_value = {"detail": "Missing file"} mock_post.return_value = mock_response - response = httpx.post(f"{BASE_URL}/summarize/process-pdf", files={}) + response = httpx.post(f"{BASE_URL}/process-pdf/", files={}) assert response.status_code == 422 assert response.json() == {"detail": "Missing file"} @@ -314,7 +314,7 @@ def test_get_grade_empty_storage(mock_post): mock_response.json.return_value = {"detail": "No issues have been processed yet."} mock_post.return_value = mock_response - response = httpx.post(f"{BASE_URL}/summarize/get-grade") + response = httpx.post(f"{BASE_URL}/get-grade/") assert response.status_code == 400 assert response.json() == {"detail": "No issues have been processed yet."} @@ -422,7 +422,7 @@ def test_summarize_endpoint_valid_payload(mock_post): response = httpx.post(f"{BASE_URL}/summarize", json=payload) # Assertions assert response.status_code == 200 - assert response.json() == {"summary": "This is a summarized text"} + assert response.json() == {"summary": "This is a summarized text."} @patch("httpx.post") def test_summarize_endpoint_empty_payload(mock_post):