diff options
author | Martin Indra <martin.indra@mgn.cz> | 2017-10-25 20:13:53 +0200 |
---|---|---|
committer | Jon Wayne Parrott <jonwayne@google.com> | 2017-10-25 11:13:53 -0700 |
commit | e7dad83893e19a96d6469b25e1e275273b54f489 (patch) | |
tree | 9c8e104dbc20ebb03b388719b814276f6fc28288 /tests/unit/test_exceptions.py | |
parent | 6873d1439a53fbb97c98829371aa6d8b77dcbb45 (diff) | |
download | python-api-core-e7dad83893e19a96d6469b25e1e275273b54f489.tar.gz |
Fix parsing of API errors with Unicode err message (#4251)
Diffstat (limited to 'tests/unit/test_exceptions.py')
-rw-r--r-- | tests/unit/test_exceptions.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit/test_exceptions.py b/tests/unit/test_exceptions.py index df159be..3a77447 100644 --- a/tests/unit/test_exceptions.py +++ b/tests/unit/test_exceptions.py @@ -135,6 +135,22 @@ def test_from_http_response_bad_json_content(): assert exception.message == 'POST https://example.com/: unknown error' +def test_from_http_response_json_unicode_content(): + response = make_response(json.dumps({ + 'error': { + 'message': u'\u2019 message', + 'errors': ['1', '2'] + } + }).encode('utf-8')) + + exception = exceptions.from_http_response(response) + + assert isinstance(exception, exceptions.NotFound) + assert exception.code == http_client.NOT_FOUND + assert exception.message == u'POST https://example.com/: \u2019 message' + assert exception.errors == ['1', '2'] + + def test_from_grpc_status(): message = 'message' exception = exceptions.from_grpc_status( |