Skip to content
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

Open
wants to merge 7 commits into
base: crest-work
Choose a base branch
from

Conversation

hpatel41
Copy link
Contributor

Description of change

TDL-17512: Add missing tap-tester tests

  • added all fields test
  • missing assertions in discovery, start date, bookmark test cases.

QA steps

  • automated tests passing
  • manual qa steps passing (list below)

Risks

Rollback steps

  • revert this branch

@hpatel41 hpatel41 changed the base branch from master to crest-work February 2, 2022 06:03
@savan-chovatiya savan-chovatiya marked this pull request as ready for review February 2, 2022 07:23
tests/base.py Outdated
Comment on lines 135 to 139
# 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"}
Copy link
Contributor

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.

Copy link
Contributor Author

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))
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added function comment.

Copy link
Contributor

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))
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added function comment.

Comment on lines 151 to 152
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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment.

@hpatel41 hpatel41 requested a review from savan-chovatiya March 4, 2022 05:41
return return_value

@staticmethod
def get_credentials(original_credentials: bool = True):
Copy link
Contributor

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?

Copy link
Contributor Author

@hpatel41 hpatel41 Mar 9, 2022

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.

tests/test_start_date.py Outdated Show resolved Hide resolved
@hpatel41 hpatel41 requested a review from dbshah1212 March 9, 2022 08:42
Copy link
Contributor

@kspeer825 kspeer825 left a 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
Comment on lines 135 to 140
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"}
Copy link
Contributor

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.

Copy link
Contributor Author

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:
Copy link
Contributor

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

Copy link
Contributor Author

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.
Copy link
Contributor

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good addition

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
Copy link
Contributor

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

Copy link
Contributor Author

@hpatel41 hpatel41 Apr 11, 2022

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.

@hpatel41 hpatel41 requested a review from kspeer825 April 11, 2022 10:23
Comment on lines +182 to +183
for record_replication_key in record_replication_keys:
self.assertGreaterEqual(record_replication_key, start_date)
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary assertion.

@hpatel41 hpatel41 requested a review from kspeer825 April 11, 2022 13:46
@hpatel41 hpatel41 changed the base branch from crest-work to api-sdk-version-change-and-fields-addition April 12, 2022 07:02
@hpatel41 hpatel41 changed the base branch from api-sdk-version-change-and-fields-addition to crest-work April 12, 2022 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants