aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/test_exceptions.py
diff options
context:
space:
mode:
authorBu Sun Kim <8822365+busunkim96@users.noreply.github.com>2020-10-06 15:30:47 -0600
committerGitHub <noreply@github.com>2020-10-06 15:30:47 -0600
commita85533903c57be4809fe76435e298409e0903931 (patch)
treefd08ccaf4d4e366031582c5bf69314ea620c23f5 /tests/unit/test_exceptions.py
parent000d0a04b6c539aa6a6aae0a487665341be484c4 (diff)
downloadpython-api-core-a85533903c57be4809fe76435e298409e0903931.tar.gz
fix: map LRO errors to library exception types (#86)
Fixes #15 🦕 Errors raised by long running operations are currently always type GoogleAPICallError. Use the status code to create a more specific exception type.
Diffstat (limited to 'tests/unit/test_exceptions.py')
-rw-r--r--tests/unit/test_exceptions.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/unit/test_exceptions.py b/tests/unit/test_exceptions.py
index 040ac8a..fb29015 100644
--- a/tests/unit/test_exceptions.py
+++ b/tests/unit/test_exceptions.py
@@ -161,6 +161,17 @@ def test_from_grpc_status():
assert exception.errors == []
+def test_from_grpc_status_as_int():
+ message = "message"
+ exception = exceptions.from_grpc_status(11, message)
+ assert isinstance(exception, exceptions.BadRequest)
+ assert isinstance(exception, exceptions.OutOfRange)
+ assert exception.code == http_client.BAD_REQUEST
+ assert exception.grpc_status_code == grpc.StatusCode.OUT_OF_RANGE
+ assert exception.message == message
+ assert exception.errors == []
+
+
def test_from_grpc_status_with_errors_and_response():
message = "message"
response = mock.sentinel.response