This repository has been archived by the owner on May 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add error improvements and bump 0.6.2
Add error improvements
- Loading branch information
Showing
3 changed files
with
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""Define consts for the pysmartthings package.""" | ||
|
||
__title__ = "pysmartthings" | ||
__version__ = "0.6.1" | ||
__version__ = "0.6.2" |
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,40 @@ | ||
"""Tests for the error module.""" | ||
|
||
from pysmartthings.errors import APIResponseError | ||
|
||
|
||
class TestAPIResponseError: | ||
"""Tests for the APIResponseError class.""" | ||
|
||
@staticmethod | ||
def test_is_target_error(): | ||
"""Tests the initialization.""" | ||
# Arrange/Act | ||
data = { | ||
"requestId": "8B66A345-03B0-477F-A8A6-1A1CF0277040", | ||
"error": { | ||
"code": "ConstraintViolationError", | ||
"message": "The request is malformed.", | ||
"details": [ | ||
{ | ||
"code": "TargetTimeoutError", | ||
"target": "https://blah.blah/blah", | ||
"message": "Upstream target timed out", | ||
"details": [] | ||
} | ||
] | ||
} | ||
} | ||
error = APIResponseError(None, None, data=data) | ||
# Assert | ||
assert error.is_target_error() | ||
assert error.raw_error_response == data | ||
assert error.request_id == '8B66A345-03B0-477F-A8A6-1A1CF0277040' | ||
assert error.error.code == 'ConstraintViolationError' | ||
assert error.error.message == 'The request is malformed.' | ||
assert len(error.error.details) == 1 | ||
detail = error.error.details[0] | ||
assert detail.code == 'TargetTimeoutError' | ||
assert detail.target == "https://blah.blah/blah" | ||
assert detail.message == "Upstream target timed out" | ||
assert not detail.details |