-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a947d3
commit 99e3f83
Showing
3 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from fastapi.testclient import TestClient | ||
from app.main import app | ||
|
||
test_client = TestClient(app) | ||
|
||
|
||
def test_value_error_handler(): | ||
# Simulate an endpoint that raises a ValueError (e.g., by sending an invalid CURIE) | ||
response = test_client.get("/api/ontol/labeler?id=@base:invalid") | ||
|
||
# Verify that the global exception handler for ValueErrors, rewrites as an internal server error code. | ||
assert response.status_code == 400 | ||
response = test_client.get(f"/api/gp/P05067/models") | ||
|
||
|
||
def test_value_error_curie(): | ||
response = test_client.get(f"/api/gp/P05067/models") | ||
assert response.status_code == 400 | ||
assert response.json() == {"message": "Value error occurred: Invalid CURIE format"} | ||
|
||
|
||
def test_ncbi_taxon_error_handling(): | ||
response = test_client.get("/api/taxon/NCBITaxon%3A4896/models") | ||
assert response.status_code == 200 |