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-13615: Add Locations stream and TDL-13614: Add Inventory Levels stream #114

Merged
merged 26 commits into from
Oct 4, 2021

Conversation

hpatel41
Copy link
Contributor

@hpatel41 hpatel41 commented Jul 30, 2021

Description of change

TDL-13615: Add locations data

  • Added locations as an INCREMENTAL stream.

TDL-13614: Add Inventory Levels stream

  • Added Inventory Levels as an INCREMENTAL stream.

TDL-14697: Properly catch the error of missing OAuth scopes

  • Added proper error message for the forbidden error.

QA steps

  • Added locations and Inventory Levels in the tap-tester tests.

Risks

Rollback steps

  • revert this branch

@hpatel41 hpatel41 changed the title Tdl 13615 add locations stream TDL-13615: add 'locations' stream Jul 30, 2021
@savan-chovatiya savan-chovatiya changed the title TDL-13615: add 'locations' stream TDL-13615: Add Locations stream and TDL-13614: Add Inventory Levels stream Jul 30, 2021
@hpatel41 hpatel41 marked this pull request as ready for review August 23, 2021 09:41
# skip 'locations' stream as there is not much info about
# limit of records returned in 1 page
# Documentation: https://help.shopify.com/en/manual/locations/setting-up-your-locations
if stream in ['locations']:
Copy link
Contributor

@dbshah1212 dbshah1212 Aug 31, 2021

Choose a reason for hiding this comment

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

Can we remove the location stream from the testable_streams. Remove location stream from line no. 23.

Copy link
Contributor

@savan-chovatiya savan-chovatiya Sep 1, 2021

Choose a reason for hiding this comment

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

Removed locations stream from testable_streams as per suggestion.

actual_sync = list(LOCATIONS_OBJECT.sync())

# Verify that only 2 record syncs
self.assertEqual(actual_sync, expected_sync)

Choose a reason for hiding this comment

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

@namrata270998 Please write test case to check the max_bookmark value in sync function

Copy link
Contributor

Choose a reason for hiding this comment

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

Added an assertion to check with what value is the update_bookmark() function called.


with self.subTest(store="store_2"):
conn_id = self.create_connection(original_properties=False, original_credentials=False)
self.pagination_test(conn_id, self.store_2_streams)
self.pagination_test(conn_id, self.store_2_streams - excepted_streams)
Copy link
Contributor

Choose a reason for hiding this comment

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

For this test could you please add the assertions that verify records are unique across pages by checking primary key values. It should leverage tuples in case of any compound primary keys and the assertCountEqual method. https://github.com/singer-io/tap-hubspot/blob/290e5c051839b01e43739d25e1c46b6ddef5a749/tests/test_hubspot_pagination_test.py#L118-L127

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done the changes.

@hpatel41 hpatel41 requested a review from kspeer825 September 16, 2021 07:15
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.

Looks good thanks!

@savan-chovatiya savan-chovatiya requested review from luandy64 and zachharris1 and removed request for KAllan357 and savan-chovatiya September 23, 2021 10:45

expected_sync = [LOCATION_3.to_dict(), LOCATION_4.to_dict()]
mock_get_locations_data.return_value = [
LOCATION_1, LOCATION_2, LOCATION_3, LOCATION_4]
Copy link
Contributor

Choose a reason for hiding this comment

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

Line 32/33 make it one single line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 42 to 46
max_bookmark = strptime_to_utc("2021-08-14T01:57:05-04:00")

# Verify that maximum replication key of all keys is updated as bookmark
mock_update_bookmark.assert_called_with(
utils.strftime(max_bookmark))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we want to have extra conversion for max_bookmark?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because max_bookmark is in datetime format and the bookmark date is called in the string format.

Comment on lines 160 to 163
raise ShopifyError(exc, 'Add read_inventory scope for access token and '
'Re-authorize the connection to sync '
'Inventory Levels and Inventory Items streams.') \
from exc
Copy link
Contributor

Choose a reason for hiding this comment

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

Change it to "Add read_inventory scope for access token, re-authorize the connect to sync and get Inventory levels /Inventory items streams

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

for parent_object in selected_parent.get_locations_data():
inventory_levels = self.get_inventory_levels(parent_object.id, bookmark)
for inventory_level in inventory_levels:
yield inventory_level
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use yield from? What is difference between line 28?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the code and used "yield from"


@shopify_error_handling
def get_locations_data(self):
location_page = self.replication_object.find()
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any parameters being missed for find like API for inventory levels?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the location API documentation does not have the parameters like the inventory levels.

@luandy64 luandy64 mentioned this pull request Oct 1, 2021
2 tasks
@hpatel41 hpatel41 merged commit 9e46b39 into master Oct 4, 2021
tmck-code pushed a commit to lexerdev/tap-shopify that referenced this pull request Feb 3, 2022
…tream (singer-io#114)

* added locations stream

* pylint resolve

* added location as full table

* set replication key to none

* test: added location in test

* pylint resolve

* test: set api limit 0 for locations stream

* added unit test to run on cci

* TDL-13614: Added Inventory Level stream

* Resolved pylint failure

* Added error message for read_inventory scope requirement

* Resolved pylint failure

* added error decorator in locations stream

* skip if updated at is not found

* updated location stream code to use replication key value as bookmark

* Updated pagination test for locations stream

* Added unit tests

* Updated unit tests as per suggestion

* added 2 fields in locations stream

* updated the test case according to the comment

* made changes according to the comments

* updated code

Co-authored-by: savan-chovatiya <[email protected]>
Co-authored-by: savan-chovatiya <[email protected]>
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.

7 participants