Skip to content

Commit

Permalink
still not showing up
Browse files Browse the repository at this point in the history
  • Loading branch information
AditiR-42 committed Dec 11, 2024
1 parent 60c0888 commit 277001a
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/models/tests/integration/test_api_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}/summarize/process-pdf", files=files)

# Assertions
assert response.status_code == 200
Expand All @@ -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}/summarize/get-grade", json={"input": "test data"})

assert response.status_code == 200
assert response.json() == {"grade": "A"}
Expand Down Expand Up @@ -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}/summarize/get-grade", json={"invalid": "data"})
assert response.status_code == 422
assert response.json() == {"error": "Invalid data format"}

Expand All @@ -103,20 +103,20 @@ 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}/summarize/get-grade", json={"invalid": "data"})
assert response.status_code == 422
assert response.json() == {"error": "Invalid data format"}

@patch("httpx.post")
def test_process_pdf_invalid_file(mock_post):
"""Test /process-pdf/ endpoint with invalid file format."""
"""Test /process-pdf endpoint with invalid file format."""
mock_response = MagicMock()
mock_response.status_code = 400
mock_response.json.return_value = {"error": "Invalid file type"}
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}/summarize/process-pdf", files=files)

assert response.status_code == 400
assert response.json() == {"error": "Invalid file type"}
Expand Down Expand Up @@ -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}/summarize/process-pdf",
files=files,
data={"project_id": "invalid_project", "location_id": "us-central1", "endpoint_id": "3504346967373250560"}
)
Expand All @@ -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}/summarize/process-pdf", files=files)

assert response.status_code == 400
assert response.json() == {"detail": "A valid PDF file is required."}
Expand All @@ -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}/summarize/get-grade")
assert response.status_code == 400
assert response.json() == {
"detail": "No issues have been processed yet. Please process a PDF first."
Expand All @@ -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}/summarize/get-grade")
assert response.status_code == 500
assert response.json() == {"detail": "Error grading issues: Invalid data"}

Expand Down Expand Up @@ -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}/summarize/process-pdf", files=files)
assert response.status_code == 500
assert response.json() == {"detail": "Error processing file: Unexpected error"}

Expand All @@ -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}/summarize/process-pdf", files=files)

assert response.status_code == 400
assert response.json() == {"detail": "A valid PDF file is required."}
Expand All @@ -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}/summarize/process-pdf", files={})
assert response.status_code == 422
assert response.json() == {"detail": "Missing file"}

Expand All @@ -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}/summarize/get-grade")
assert response.status_code == 400
assert response.json() == {"detail": "No issues have been processed yet."}

Expand Down

0 comments on commit 277001a

Please sign in to comment.