-
Notifications
You must be signed in to change notification settings - Fork 19
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 681 add retry mechanism #30
Conversation
tap_klaviyo/utils.py
Outdated
|
||
def raise_for_error(response): | ||
try: | ||
json_resp = response.json() |
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.
@harshpatel4crest Can you please get the response of response.raise_for_status() here and except the HTTTError in the exception.
Please refer to the tap-Xero code (https://github.com/singer-io/tap-xero/pull/85/files#diff-43d32c99c6992e01f4dbdb49df5e372db029dae0de306b9191283ef21b852438R216) for the same
tests/test_exception_handling.py
Outdated
import singer | ||
|
||
class Mockresponse: | ||
def __init__(self, resp, status_code, content=None, headers=None, raise_error=False): |
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.
@harshpatel4crest You can make resp an optional argument.
class Mockresponse:
def __init__(self, status_code, resp={}, content=None, headers=None, raise_error=False):
self.json_data = resp
...
def klaviyo_400_error(*args, **kwargs):
return Mockresponse(json_str, 400, raise_error=True)
Please follow the above code for the remaining functions
class TestBackoff(unittest.TestCase): | ||
|
||
@mock.patch('requests.Session.request', side_effect=klaviyo_400_error) | ||
def test_400_error(self, klaviyo_400_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.
@harshpatel4crest Can you also add a positive scenario 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.
Please change some of the error message text. Also Pylint is failing so please get that fixed as well.
tap_klaviyo/utils.py
Outdated
}, | ||
403: { | ||
"raise_exception": KlaviyoForbiddenError, | ||
"message": "Request is missing or has an invalid API key." |
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 adjust the message here to say "Invalid authorization credentials or permissions."
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.
I have added the desired string, however I have taken the string from Klaviyo Documentation https://www.klaviyo.com/docs/api/lists.
So, let me know if want to revert the change.
tap_klaviyo/utils.py
Outdated
}, | ||
500: { | ||
"raise_exception": KlaviyoInternalServiceError, | ||
"message": "Something is wrong on Klaviyo's end." |
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 also adjust this to say "Internal Service Error from Klaviyo"
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.
Added the string in message
Can you resolve the conflicts? |
@KAllan357 |
Description of change
Manual QA steps
Risks
Rollback steps