-
Notifications
You must be signed in to change notification settings - Fork 88
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-17512: Add missing tap-tester tests #134
base: crest-work
Are you sure you want to change the base?
Conversation
tests/base.py
Outdated
# removed "abandoned_checkouts", as per the Doc: | ||
# https://help.shopify.com/en/manual/orders/abandoned-checkouts?st_source=admin&st_campaign=abandoned_checkouts_footer&utm_source=admin&utm_campaign=abandoned_checkouts_footer#review-your-abandoned-checkouts | ||
# abandoned checkouts are saved in the Shopify admin for three months. | ||
# Every Monday, abandoned checkouts that are older than three months are removed from your admin. | ||
return set(self.expected_metadata().keys()) - {"abandoned_checkouts"} |
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.
Add comments about the unavailability of the POST call with a reference link.
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 comment in the test cases.
if md_entry['breadcrumb'] != []: | ||
actual_fields.append(md_entry['breadcrumb'][1]) | ||
# Verify there are no duplicate/conflicting metadata entries. | ||
self.assertEqual(len(actual_fields), len(set(actual_fields)), msg="There are duplicate entries in the fields of '{}' stream".format(stream)) |
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.
Add a comment about this assertion at the function(test_run()) level comment above.
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 function comment.
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.
Good addition
target_mark = second_min_bookmarks.get(stream, {"mark": None}) | ||
target_value = next(iter(target_mark.values())) # there should be only one | ||
# Verify by primary key values, that all records of the 2nd sync are included in the 1st sync since 2nd sync has a later start date. | ||
self.assertTrue(primary_keys_sync_2.issubset(primary_keys_sync_1)) |
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.
Add a comment about this assertion at the function(test_run()) level comment above.
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 function comment.
tests/test_start_date.py
Outdated
for start_date, target_mark in zip((first_sync_start_date, second_sync_start_date), (first_sync_target_mark, second_sync_target_mark)): | ||
target_value = next(iter(target_mark.values())) # there should be only one |
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.
Add a comment here about the addition of for loop.
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 comment.
tests/test_all_fields.py
Outdated
return return_value | ||
|
||
@staticmethod | ||
def get_credentials(original_credentials: bool = 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.
It is already available in base.py, Any reason for redefining 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.
Updated the test case to use the function from base test file.
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.
This is good work. I left one suggestion for the start date test. Also the abandoned_checkouts does not need to be removed. We periodically refresh that data using tooling outside of tap-tester.
tests/base.py
Outdated
return set(self.expected_metadata().keys()) | ||
# removed "abandoned_checkouts", as per the Doc: | ||
# https://help.shopify.com/en/manual/orders/abandoned-checkouts?st_source=admin&st_campaign=abandoned_checkouts_footer&utm_source=admin&utm_campaign=abandoned_checkouts_footer#review-your-abandoned-checkouts | ||
# abandoned checkouts are saved in the Shopify admin for three months. | ||
# Every Monday, abandoned checkouts that are older than three months are removed from your admin. | ||
# Also no POST call is available for this endpoint: https://shopify.dev/api/admin-rest/2022-01/resources/abandoned-checkouts | ||
return set(self.expected_metadata().keys()) - {"abandoned_checkouts"} |
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 put this stream back, we have internal tooling for generating these records outside of the base test suite.
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.
Included abandoned_checkouts stream
tests/base.py
Outdated
@@ -301,7 +306,12 @@ def __init__(self, *args, **kwargs): | |||
super().__init__(*args, **kwargs) | |||
self.start_date = self.get_properties().get("start_date") | |||
self.store_1_streams = {'custom_collections', 'orders', 'products', 'customers', 'locations', 'inventory_levels', 'inventory_items', 'events'} | |||
self.store_2_streams = {'abandoned_checkouts', 'collects', 'metafields', 'transactions', 'order_refunds', 'products', 'locations', 'inventory_levels', 'inventory_items', 'events'} | |||
# removed 'abandoned_checkouts' from store 2 streams, as per the Doc: |
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 put back, see previous comment
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.
Included abandoned_checkouts stream
self.expected_replication_keys().get(stream, set()), | ||
msg="The fields sent to the target are not the automatic fields" | ||
) | ||
|
||
# Verify that all replicated records have unique primary key values. |
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.
Good addition
if md_entry['breadcrumb'] != []: | ||
actual_fields.append(md_entry['breadcrumb'][1]) | ||
# Verify there are no duplicate/conflicting metadata entries. | ||
self.assertEqual(len(actual_fields), len(set(actual_fields)), msg="There are duplicate entries in the fields of '{}' stream".format(stream)) |
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.
Good addition
tests/test_start_date.py
Outdated
first_sync_start_date = self.get_properties()["start_date"] | ||
second_sync_start_date = self.start_date | ||
|
||
# loop over minimum bookmark and the start date/state file date for each syncs to verify |
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.
The original implementation here was very difficult to follow. These changes are helpful, but can this be updated to conform to current best practices? See https://github.com/singer-io/tap-helpscout/blob/ad2b6192a5f5fad8c5bd0573cb38bf38bd5962dd/tests/test_helpscout_start_date.py#L109-L122
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.
The first 2 assertions are already included in our test case at line no. 141 and 147. Added assertion of replication key-values synced is greater than or equal to the start date.
for record_replication_key in record_replication_keys: | ||
self.assertGreaterEqual(record_replication_key, 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.
I think the try except and assertion above are unnecessary. The minimum replication key value is covered by this assertion.
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.
Removed unnecessary assertion.
Description of change
TDL-17512: Add missing tap-tester tests
QA steps
Risks
Rollback steps