-
Notifications
You must be signed in to change notification settings - Fork 2
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
TDL-19745 unittests and retrylogic for 500 exceptions #11
Conversation
…nger-io/tap-dixa into TDL-19674-bookmarking_strategy_bugfix
…inger-io/tap-dixa into TDL-19668-overlapping-timeslots_bugfix
Co-authored-by: Collin Simon <cosimon@users.noreply.github.com>
Co-authored-by: Collin Simon <cosimon@users.noreply.github.com>
@rdeshmukh15 can u add Unit Tests stage in circleCI config.yml. |
@kethan1122 : Added the changes suggested in config.yaml |
response = IncrementalStream.get_interval(self) | ||
except InvalidInterval as e : | ||
expected_error_message = "invalid interval provided" | ||
assert str(e) == expected_error_message |
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.
Use unittest assert 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.
Done the changes as suggested.
tests/unittests/test_backoff.py
Outdated
def mocked_failed_429_request(*args, **kwargs): | ||
return Mockresponse('', 429, headers={}, raise_error=True) | ||
|
||
@patch("time.sleep") | ||
@patch("requests.Session.request", side_effect=mocked_failed_429_request) | ||
class Test_Client(unittest.TestCase): | ||
|
||
def test_too_many_requests_429_error(self, mocked_send, mocked_sleep): | ||
client = Client(api_token="test") | ||
|
||
try: | ||
# Verifying if the custom exception 'DixaClient429Error' is raised on receiving status code 429 | ||
_ = client.get("https://test.com", "/test") | ||
except DixaClient429Error: #as api_error: | ||
pass | ||
|
||
# Verifying the retry is happening thrice for the 429 exception | ||
self.assertEquals(mocked_send.call_count, 3) |
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.
Observed that we have not implemented backoff and retry for 5XX in the tap, implement that and add respective unittests as well.
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.
Done
- verify exceptions for applicable http error codes
HTTPTimeout is not implemented, please implement it. |
try: | ||
self.client_obj.get("https://test.com", "/test") | ||
except exceptions.DixaClientError as _: | ||
self.assertEqual(str(_), "Server Error") |
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 we have descriptive error message for 5XX than "Server Error"
?
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.
Made the changes as per suggestion.
tap_dixa/exceptions.py
Outdated
class DixaClient5xxError(DixaClientError): | ||
pass |
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.
Move DixaClient5xxError class to below DixaClient4xxError.
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.
Done
Description of change
Covered below scenarios in Unit Test Cases :
Tap Changes:
Manual QA steps
Risks
Rollback steps