-
Notifications
You must be signed in to change notification settings - Fork 16
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 #17 from AdCombo/16-fix-format-http-exception
fix format_http_exception error
- Loading branch information
Showing
2 changed files
with
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from unittest.mock import Mock | ||
|
||
from flask_combo_jsonapi import JsonApiException | ||
from flask_combo_jsonapi.errors import format_http_exception | ||
|
||
|
||
def test_format_http_exception__value_error(): | ||
ex = Mock() | ||
ex.code = 'f405' | ||
|
||
assert format_http_exception(ex) is None | ||
|
||
|
||
def test_format_http_exception__type_error(): | ||
ex = Mock() | ||
ex.code = 'not_int' | ||
|
||
assert format_http_exception(ex) is None | ||
|
||
|
||
def test_format_http_exception__success(): | ||
ex = Mock() | ||
ex.code = 400 | ||
|
||
res = format_http_exception(ex) | ||
|
||
assert isinstance(res, JsonApiException) | ||
assert res.status == '400' |