Skip to content

test: minor updates to a few testcases #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ dist: jammy
matrix:
include:
- python: 3.8
- python: 3.9
- python: 3.10
- python: 3.11
- python: 3.12
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't seem right to build on FIVE versions of python so I removed python 3.9 so we would still be building on the current supported min version (3.8).


cache: pip3

Expand Down
5 changes: 5 additions & 0 deletions test/test_api_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def test_api_exception():
mock_response = requests.get('https://test-errormessage.com', timeout=None)
exception = ApiException(500, http_response=mock_response)
assert exception.message == 'IAM error message'
assert exception.http_response.text == '{"errorMessage": "IAM error message"}'
assert exception.http_response.content == b'{"errorMessage": "IAM error message"}'
assert exception.http_response.json() == {'errorMessage': 'IAM error message'}

responses.add(
responses.GET,
Expand All @@ -86,3 +89,5 @@ def test_api_exception():
exception = ApiException(500, http_response=mock_response)
assert exception.message == 'plain text error'
assert str(exception) == 'Error: plain text error, Status code: 500 , X-global-transaction-id: xx'
assert exception.http_response.text == 'plain text error'
assert exception.http_response.content == b'plain text error'
3 changes: 1 addition & 2 deletions test/test_jwt_token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ def test_is_token_expired():


def test_abstract_class_instantiation():
with pytest.raises(TypeError) as err:
with pytest.raises(TypeError, match=r"^Can't instantiate abstract class JWTTokenManager.*$"):
JWTTokenManager(None)
assert str(err.value).startswith("Can't instantiate abstract class JWTTokenManager with abstract")


def test_disable_ssl_verification():
Expand Down
8 changes: 1 addition & 7 deletions test/test_token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,8 @@ def _save_token_info(self, token_response: dict) -> None:


def test_abstract_class_instantiation():
with pytest.raises(TypeError) as err:
with pytest.raises(TypeError, match=r"^Can't instantiate abstract class TokenManager.*$"):
TokenManager(None)
assert (
str(err.value) == "Can't instantiate abstract class "
"TokenManager with abstract methods "
"_save_token_info, "
"request_token"
)


def requests_request_spy(*args, **kwargs):
Expand Down