-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from nathanegillett/3354
Return XML error responses for upload API [RHELDST-3354]
- Loading branch information
Showing
3 changed files
with
55 additions
and
1 deletion.
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,30 @@ | ||
from fastapi import HTTPException | ||
|
||
import pytest | ||
import mock | ||
|
||
from exodus_gw.gateway import custom_http_exception_handler | ||
|
||
TEST_KEY = "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c" | ||
|
||
|
||
@pytest.mark.asyncio | ||
@pytest.mark.parametrize( | ||
"endpoint, media_type", | ||
[ | ||
("/upload/foo/%s" % TEST_KEY, "xml"), | ||
("/foo/publish/%s" % TEST_KEY, "json"), | ||
("/healthcheck", "json"), | ||
("/whoami", "json"), | ||
], | ||
ids=["upload", "publish", "healthcheck", "whoami"], | ||
) | ||
async def test_custom_http_exception_handler(endpoint, media_type): | ||
# Verify that HTTPExceptions raised are handled according to endpoint. | ||
# Expand list of endpoints as needed. | ||
|
||
request = mock.Mock(scope={"path": endpoint}) | ||
err = HTTPException(status_code=600, detail="testing response") | ||
response = await custom_http_exception_handler(request, err) | ||
|
||
assert response.media_type == "application/%s" % media_type |