-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat 1695 testing concept #15
Conversation
… of integration tests for L1 layer.
…what can be improved.
…t use of final url.
…feat-1695-testing-concept
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work - it was a tricky set of testing to organise - couple of minor changes suggested but otherwise looks good.
""" | ||
|
||
@pytest.mark.asyncio | ||
async def test_http_client_get_request_mock(httpx_mock: HTTPXMock) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is httpx_mock a fixture - if so could it be put with the other fixtures above? or am I missing something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
httpx_mock is a fixture imported from pytest-httpx.
assert is_exception_in_chain(exec_info.value, httpx.ConnectError), "httpx.ConnectError not found in exception chain" | ||
assert error_message in str(exec_info.value), f"Error message: {error_message} not found in Exception." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool this seems good
tests/unit_helpers.py
Outdated
class MockedAuthService(AuthManager): | ||
|
||
def __init__(self) -> None: | ||
self.token = "mock_access_token" | ||
self.refresh_token = "mock_refresh_token" | ||
self.public_key = "mock_public_key" | ||
|
||
def refresh_tokens(self) -> None: | ||
"""Simulate refreshing tokens.""" | ||
self.token = "refreshed_mock_access_token" | ||
self.refresh_token = "refreshed_mock_refresh_token" | ||
|
||
def force_refresh(self) -> None: | ||
"""Simulate force refreshing tokens.""" | ||
self.refresh_tokens() | ||
|
||
def get_token(self) -> str: | ||
"""Return the mock access token.""" | ||
return self.token | ||
|
||
def get_auth(self) -> HttpxBearerAuth: | ||
"""Return a mock HttpxBearerAuth object.""" | ||
return HttpxBearerAuth(token=self.token) | ||
|
||
def validate_token(self, tokens: Tokens) -> bool: | ||
"""Simulate token validation.""" | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you simplify this to just the base class methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay I have updated accordingly.
tests/unit_helpers.py
Outdated
while current_exception: | ||
if isinstance(current_exception, exception_type): | ||
return True | ||
current_exception = current_exception.__context__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this attribute always exist? Maybe wrap a try/catch around this line and if it fails return False - feels a little dangerous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay I see what you mean here, I think given that all our exceptions are using default Python Exceptions/ our custom exceptions are inherited from Exception itself, I think the context attribute will always exist, but just for safety I will wrap a try-catch around it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what type of exceptions to throw with this, so just throwing a general Exception in the try except block.
… robustness of exception chaining function.
Jira-1695 (Major/Minor/Bug Fix): Major
JIRA Ticket 1695
Checklist
Description
release_to_pyPI
configuration, thus we should not have to use the hacky workaround to release the library.Notes for reviewer