-
Notifications
You must be signed in to change notification settings - Fork 47
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-20767 resetting bookmark date to start date #178
Conversation
c6aa936
to
9b3ec25
Compare
… have events update date older than 30 days
tap_stripe/__init__.py
Outdated
if max_created != bookmark_value and (bookmark_value != start_date or flag_value is True): | ||
reset_bookmark_for_event_updates(is_sub_stream, stream_name, sub_stream_name, start_date) | ||
raise Exception("Provided current bookmark date for event updates is older than 30 days."\ | ||
" Hence, resetting the bookmark date of respective parent/child stream to start date.") |
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.
could you add the name of the stream(s) to the exception message
event_update_window_size = Context.event_update_window_size | ||
events_update_date_window_size = int(60 * 60 * 24 * event_update_window_size) # event_update_window_size in seconds | ||
sync_start_time = dt_to_epoch(utils.now()) | ||
start_date = int(utils.strptime_to_utc(Context.config["start_date"]).timestamp()) |
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.
Since theres a variable for start_date now, it can be used on line 971 and 978
tap_stripe/__init__.py
Outdated
@@ -952,9 +952,11 @@ def sync_event_updates(stream_name, is_sub_stream): | |||
or when called through only child stream i.e. when parent is not selected. | |||
''' | |||
LOGGER.info("Started syncing event based updates") | |||
flag_value = 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.
could this variable name be more descriptive
# Verify warning message for bookmark of less than last 30 days. | ||
self.assertEqual(mock_logger.mock_calls, expected_logger_warning) | ||
with self.assertRaises(Exception) as e: | ||
sync_event_updates('charges', 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.
Could you add assertions around the altered state after the 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.
Added the test where we can check he call count, not added the assertion to compare the state because reset_bookmark_for_event_updates function doesn't return anything.
@mock.patch('tap_stripe.LOGGER.warning') | ||
def test_sync_event_updates_bookmark_before_last_7_days(self, mock_logger, mock_write_bookmark, mock_stripe_event, mock_utils_now): | ||
@mock.patch('singer.utils.now', return_value = datetime.datetime.strptime("2023-05-10T08:30:50Z", "%Y-%m-%dT%H:%M:%SZ")) | ||
def test_sync_event_updates_bookmark_before_last_30_days(self, mock_utils_now, mock_stripe_event): |
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.
also add a test where two streams are selected
Description of change
Manual QA steps
Tested following scenarios :
- Scenario 1 : subscriptions and subscription_items stream are selected, passed 15th march 2023 as created in state file for subscriptions and subscriptions_events and 1st may 2023 as created for subscription_items
==>
In the first run, it should raise the exception and reset the created for
subscriptions
to start_date and removesubscriptions_events
key from the state and same should happen with thesubscription_items
as wellIn the second run, it should fetch the historical data for
subscriptions
and thesubscription_items
stream- Scenario 2 : If only one stream is selected and it has quite older(> 30 days) event updates then
==>
Risks
Rollback steps