-
Notifications
You must be signed in to change notification settings - Fork 18
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-20155 Add missing tap tester #46
Conversation
tests/base.py
Outdated
BOOKMARK_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ" | ||
INCREMENTAL = "INCREMENTAL" | ||
FULL_TABLE = "FULL_TABLE" | ||
ADITIONAL_AUTOMATIC = "aditional-automatic-fields" |
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.
ADITIONAL_AUTOMATIC = "aditional-automatic-fields" | |
ADDITIONAL_AUTOMATIC = "additional-automatic-fields" |
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 this change is left to address.
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.
tests/test_start_date.py
Outdated
|
||
# Verify bookmark key values are greater than or equal to start_date of sync 1 | ||
for start_date_key_value in start_date_key_sync_1: | ||
self.assertGreaterEqual(self.dt_to_ts(start_date_key_value), start_date_1_epoch) |
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.
Update dt_to_ts
function in a base.py to convert date as per provided format. Add additional argument in function to define the format.
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 dt_to_ts function to call with date-format.
tests/test_all_fields.py
Outdated
@@ -20,7 +57,7 @@ def test_run(self): | |||
- Verify that more than just the automatic fields are replicated for each stream. | |||
""" | |||
|
|||
expected_streams = self.expected_streams() | |||
expected_streams = self.expected_streams() - {'ad_analytics_by_creative', 'ad_analytics_by_campaign'} |
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 the above streams removal from expected_streams.
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.
We are not going to skip these streams.
tests/test_pagination.py
Outdated
@@ -39,7 +47,7 @@ def test_run(self): | |||
for message in synced_records.get(stream).get('messages') | |||
if message.get('action') == 'upsert'] | |||
|
|||
# verify records are more than page size so multiple page is working | |||
# verify records are more than page size so multiple pages are working |
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 you chunk pages and validate unique values across all pages instead of the just the first 2?
For reference https://github.com/singer-io/tap-mixpanel/blob/2cf3a86231da042f76f4e3ef9fa8c23600b6f593/tests/tap_tester/test_all_fields_pagination.py#L134-L153
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 code to validate unique values across all the pages instead of the first 2 pages.
tests/test_pagination.py
Outdated
"""Returns the connection properties""" | ||
return { | ||
"start_date" : "2018-08-21T00:00:00Z", | ||
"accounts": "503491473,502890776", |
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 use the env var instead of manually passing the account ids?
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 get_properties since we can pass multiple accounts in the env variable.
tests/test_pagination.py
Outdated
"accounts": "503491473,502890776", | ||
"page_size": 100 | ||
} | ||
|
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 if we just wanna change the start date we can change the self.start_date and use connections.ensure_connection(self, original_properties=False)
to use 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.
tests/test_all_fields.py
Outdated
"accounts": os.getenv("TAP_LINKEDIN_ADS_ACCOUNTS"), | ||
"page_size": 100 | ||
} | ||
|
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 if we just wanna change the start date we can change the self.start_date and use connections.ensure_connection(self, original_properties=False)
to use 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.
tests/test_bookmark.py
Outdated
for stream, new_state in simulated_states.items(): | ||
new_states['bookmarks'][stream] = new_state |
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.
If the calculated_states_by_stream()
returns the state in a dict format with stream name as keys, then I don't see any use of this for loop. If so can we please remove 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 code to directly assign dictionary, instead of looping through each stream.
tests/test_start_date.py
Outdated
"start_date" : self.START_DATE, | ||
"accounts": "503491473,502890776", | ||
} | ||
|
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 remove this overriden get_properties() as the start_date will be overriden in the ensure_connection(
) itself?
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.
tests/base.py
Outdated
self.PRIMARY_KEYS: {'id'}, | ||
self.REPLICATION_METHOD: 'INCREMENTAL', | ||
self.REPLICATION_METHOD: self.INCREMENTAL, | ||
self.REPLICATION_KEYS: {'last_modified_time'} |
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 OBEY_START_DATE
and use it in the start_date test.
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 OBEY_START_DATE
for the start_date
test.
tests/test_start_date.py
Outdated
@@ -49,50 +68,51 @@ def test_run(self): | |||
########################################################################## | |||
|
|||
print("REPLICATION START DATE CHANGE: {} ===>>> {} ".format(self.START_DATE, self.start_date_2)) |
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.
Replace print statements by tap-tester LOGGER
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.
Replaced print
statements with LOGGER
@@ -203,7 +218,7 @@ def expected_replication_keys(self): | |||
def run_and_verify_check_mode(self, conn_id): | |||
""" | |||
Run the tap in check mode and verify it succeeds. | |||
This should be ran prior to field selection and initial sync. | |||
This should be run before field selection and initial sync. |
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.
Replace print statements by tap-tester LOGGER in the base.py
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.
Replaced print
statements with LOGGER
tests/test_start_date.py
Outdated
@@ -12,35 +17,49 @@ def name(): | |||
return "tap_tester_linkedin_ads_start_date_test" | |||
|
|||
def test_run(self): | |||
"""Instantiate start date according to the desired data set and run the test""" | |||
|
|||
expected_streams = {"account_users"} |
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 rename this variable? On L#24 it reads little off as self.expected_streams() - expected_streams
tests/test_start_date.py
Outdated
# Checking sync test for "ad_analytics_by_campaign", "ad_analytics_by_creative" | ||
if stream in ["ad_analytics_by_campaign", "ad_analytics_by_creative"]: | ||
self.assertGreater(record_count_by_stream_1.get(stream, 0), 0) | ||
self.assertGreater(record_count_by_stream_2.get(stream, 0), 0) |
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.
Why are we handling "ad_analytics_by_campaign", "ad_analytics_by_creative"
separately? Also since this is not part of subTest()
, on failure, execution will halt.
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.
Missing record count greater than 0 for other streams.
tests/test_start_date.py
Outdated
# Verify the total number of records replicated in sync 1 is | ||
# greater than the number of records replicated in sync 2 | ||
self.assertGreater(sum(record_count_by_stream_1.values()), sum(record_count_by_stream_2.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.
Do we need this assertion becuase we are testing this for individual stream on L#151? Also on failure, execution halt denying us to find out which stream is causing the issue.
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 this assertion.
tests/test_sync_canary.py
Outdated
@@ -2,6 +2,7 @@ | |||
from base import TestLinkedinAdsBase | |||
|
|||
class LinkedinAdsSyncTest(TestLinkedinAdsBase): | |||
"""Test tap sync mode and metadata conforms to standards.""" |
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.
Aren't we covering this scenario in tests like all fields? Do we need this test?
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.
Yes, we are covering this scenario in other test cases. Removed test_sync_canary
test case.
self.assertGreater(record_count_by_stream.get(stream, 0), 0) |
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 update clear objective of this test in doc string and why we are handling it separately since this is not a standard test.
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.
There is a field reference_organization_id
in the records of the users
stream. If this field is absent, then the tap was throwing an error. It is fixed now and if this field is missing then the warning
message would print. This test case is written to verify that case. But, this scenario is already covered in the unit test case. So, removed this tap tester test case.
* Refactored dict base code to class base. * Updated parent child bookmark logic * Added detailed unit test cases. * Resolved pylint errors. * Updated Makefile. * Update Makefile to run pylint. * Updated unit test cases. * Added integration test case for parent child independent. * Updated streams.py * Updated sync to resolve pylint. * Added detailed code comments. * Added unit test to achive more coverage * Updateed get_streams_to_sync method. * Added unit test scenarios for split chunk method. * Updated Makefile to update pylint. * Remove version pins for dev requirements (#38) * Remove version pins for dev requirements * Making pylint happy * Actually make pylint happy * Add standard list of disables to the extras already discussed Co-authored-by: dylan-stitch <28106103+dylan-stitch@users.noreply.github.com> Co-authored-by: Dan Mosora <30501696+dmosorast@users.noreply.github.com> Co-authored-by: prijendev <prijen.khokhani@crestdatasys.com> * Reverted back pylint changes in config.yml * Resolved pylint errors. * typecast date_window_size with int data type. * Updated sync_without_refresh_token test. * Added missing fields in the schemas and upgraded API version. (#47) * Added missing fields in the schemas and upgraded API version. * Updated schemas and tap tester. * Updated streams file. * Updated schema files. * Updated all_field test case. * Updated all fields test case. * Replaced header param `expires_in` with `expires_at`. * Resolved pylint errors. * Replaced current_time with time.time() * Skipped fields for analytics stream that are in beta. Co-authored-by: Dylan <28106103+dsprayberry@users.noreply.github.com> Co-authored-by: dylan-stitch <28106103+dylan-stitch@users.noreply.github.com> Co-authored-by: Dan Mosora <30501696+dmosorast@users.noreply.github.com>
* Tdl 20157 Add backoff error handling for 5xx (#45) * Added backoff for all 5xx errors. * Skipped test case to check backoff. * Updated unit test case for exception handling. * Updated comment in client. * Updated error handling for 500 error. * TDL-20155 Add missing tap tester (#46) * Refactored tap tester test cases. * Updated pylint. * Added comments in the tap-tester. * Updated spell mistake in base.py * Updated base.py * Updated sync_without_resfresh_token test case. * Updated tap-tester test cases. * Removed sync_canary test case. * TDl-20154 dict base to class base implementation (#48) * Refactored dict base code to class base. * Updated parent child bookmark logic * Added detailed unit test cases. * Resolved pylint errors. * Updated Makefile. * Update Makefile to run pylint. * Updated unit test cases. * Added integration test case for parent child independent. * Updated streams.py * Updated sync to resolve pylint. * Added detailed code comments. * Added unit test to achive more coverage * Updateed get_streams_to_sync method. * Added unit test scenarios for split chunk method. * Updated Makefile to update pylint. * Remove version pins for dev requirements (#38) * Remove version pins for dev requirements * Making pylint happy * Actually make pylint happy * Add standard list of disables to the extras already discussed Co-authored-by: dylan-stitch <28106103+dylan-stitch@users.noreply.github.com> Co-authored-by: Dan Mosora <30501696+dmosorast@users.noreply.github.com> Co-authored-by: prijendev <prijen.khokhani@crestdatasys.com> * Reverted back pylint changes in config.yml * Resolved pylint errors. * typecast date_window_size with int data type. * Updated sync_without_refresh_token test. * Added missing fields in the schemas and upgraded API version. (#47) * Added missing fields in the schemas and upgraded API version. * Updated schemas and tap tester. * Updated streams file. * Updated schema files. * Updated all_field test case. * Updated all fields test case. * Replaced header param `expires_in` with `expires_at`. * Resolved pylint errors. * Replaced current_time with time.time() * Skipped fields for analytics stream that are in beta. Co-authored-by: Dylan <28106103+dsprayberry@users.noreply.github.com> Co-authored-by: dylan-stitch <28106103+dylan-stitch@users.noreply.github.com> Co-authored-by: Dan Mosora <30501696+dmosorast@users.noreply.github.com> Co-authored-by: Dylan <28106103+dsprayberry@users.noreply.github.com> Co-authored-by: dylan-stitch <28106103+dylan-stitch@users.noreply.github.com> Co-authored-by: Dan Mosora <30501696+dmosorast@users.noreply.github.com> * Updated field name in campaigns. * TDL-20798 Write Access Token in Config (#52) * Initial commit. * Replaces expires_at with expires_in. * Updated unit tests. * Added comments to explain config rewrite. * Fixed all_fields test case. * Changes - Moved the unittest scenarios to test_client.py. Fixed test_all_fields by adding reference_person_id in the missing fields. * Fixed the arguments for Linkedin client in unit test case * Removed the functionality of generating new access token from the integration test * Fixed unit test case mock value * Reverted the unit test case name Co-authored-by: Sourabh Gandhi <sgandhi@talend.com> Co-authored-by: Dylan <28106103+dsprayberry@users.noreply.github.com> Co-authored-by: dylan-stitch <28106103+dylan-stitch@users.noreply.github.com> Co-authored-by: Dan Mosora <30501696+dmosorast@users.noreply.github.com> Co-authored-by: Sourabh Gandhi <sgandhi@talend.com>
* Refactored tap tester test cases. * Updated pylint. * Added comments in the tap-tester. * Updated spell mistake in base.py * Updated base.py * Updated sync_without_resfresh_token test case. * Updated tap-tester test cases. * Removed sync_canary test case. * TDl-20154 dict base to class base implementation (#48) * Refactored dict base code to class base. * Updated parent child bookmark logic * Added detailed unit test cases. * Resolved pylint errors. * Updated Makefile. * Update Makefile to run pylint. * Updated unit test cases. * Added integration test case for parent child independent. * Updated streams.py * Updated sync to resolve pylint. * Added detailed code comments. * Added unit test to achive more coverage * Updateed get_streams_to_sync method. * Added unit test scenarios for split chunk method. * Updated Makefile to update pylint. * Remove version pins for dev requirements (#38) * Remove version pins for dev requirements * Making pylint happy * Actually make pylint happy * Add standard list of disables to the extras already discussed Co-authored-by: dylan-stitch <28106103+dylan-stitch@users.noreply.github.com> Co-authored-by: Dan Mosora <30501696+dmosorast@users.noreply.github.com> Co-authored-by: prijendev <prijen.khokhani@crestdatasys.com> * Reverted back pylint changes in config.yml * Resolved pylint errors. * typecast date_window_size with int data type. * Updated sync_without_refresh_token test. * Added missing fields in the schemas and upgraded API version. (#47) * Added missing fields in the schemas and upgraded API version. * Updated schemas and tap tester. * Updated streams file. * Updated schema files. * Updated all_field test case. * Updated all fields test case. * Replaced header param `expires_in` with `expires_at`. * Resolved pylint errors. * Replaced current_time with time.time() * Skipped fields for analytics stream that are in beta. Co-authored-by: Dylan <28106103+dsprayberry@users.noreply.github.com> Co-authored-by: dylan-stitch <28106103+dylan-stitch@users.noreply.github.com> Co-authored-by: Dan Mosora <30501696+dmosorast@users.noreply.github.com> Co-authored-by: Dylan <28106103+dsprayberry@users.noreply.github.com> Co-authored-by: dylan-stitch <28106103+dylan-stitch@users.noreply.github.com> Co-authored-by: Dan Mosora <30501696+dmosorast@users.noreply.github.com>
* Tdl 20157 Add backoff error handling for 5xx (#45) * Added backoff for all 5xx errors. * Skipped test case to check backoff. * Updated unit test case for exception handling. * Updated comment in client. * Updated error handling for 500 error. * TDL-20155 Add missing tap tester (#46) * Refactored tap tester test cases. * Updated pylint. * Added comments in the tap-tester. * Updated spell mistake in base.py * Updated base.py * Updated sync_without_resfresh_token test case. * Updated tap-tester test cases. * Removed sync_canary test case. * TDl-20154 dict base to class base implementation (#48) * Refactored dict base code to class base. * Updated parent child bookmark logic * Added detailed unit test cases. * Resolved pylint errors. * Updated Makefile. * Update Makefile to run pylint. * Updated unit test cases. * Added integration test case for parent child independent. * Updated streams.py * Updated sync to resolve pylint. * Added detailed code comments. * Added unit test to achive more coverage * Updateed get_streams_to_sync method. * Added unit test scenarios for split chunk method. * Updated Makefile to update pylint. * Remove version pins for dev requirements (#38) * Remove version pins for dev requirements * Making pylint happy * Actually make pylint happy * Add standard list of disables to the extras already discussed Co-authored-by: dylan-stitch <28106103+dylan-stitch@users.noreply.github.com> Co-authored-by: Dan Mosora <30501696+dmosorast@users.noreply.github.com> Co-authored-by: prijendev <prijen.khokhani@crestdatasys.com> * Reverted back pylint changes in config.yml * Resolved pylint errors. * typecast date_window_size with int data type. * Updated sync_without_refresh_token test. * Added missing fields in the schemas and upgraded API version. (#47) * Added missing fields in the schemas and upgraded API version. * Updated schemas and tap tester. * Updated streams file. * Updated schema files. * Updated all_field test case. * Updated all fields test case. * Replaced header param `expires_in` with `expires_at`. * Resolved pylint errors. * Replaced current_time with time.time() * Skipped fields for analytics stream that are in beta. Co-authored-by: Dylan <28106103+dsprayberry@users.noreply.github.com> Co-authored-by: dylan-stitch <28106103+dylan-stitch@users.noreply.github.com> Co-authored-by: Dan Mosora <30501696+dmosorast@users.noreply.github.com> Co-authored-by: Dylan <28106103+dsprayberry@users.noreply.github.com> Co-authored-by: dylan-stitch <28106103+dylan-stitch@users.noreply.github.com> Co-authored-by: Dan Mosora <30501696+dmosorast@users.noreply.github.com> * Updated field name in campaigns. * TDL-20798 Write Access Token in Config (#52) * Initial commit. * Replaces expires_at with expires_in. * Updated unit tests. * Added comments to explain config rewrite. * Fixed all_fields test case. * Changes - Moved the unittest scenarios to test_client.py. Fixed test_all_fields by adding reference_person_id in the missing fields. * Fixed the arguments for Linkedin client in unit test case * Removed the functionality of generating new access token from the integration test * Fixed unit test case mock value * Reverted the unit test case name Co-authored-by: Sourabh Gandhi <sgandhi@talend.com> * Upgrade creatives api endpoint (#57) * modify code for the creatives API endpoint update * add specific headers for creatives endpoint and update the comments with the documentation link * make pylint happy. fix the integration tests. * update readme file * remove the older unit test case file * major bump version changes --------- Co-authored-by: Prijen Khokhani <88327452+prijendev@users.noreply.github.com> Co-authored-by: Dylan <28106103+dsprayberry@users.noreply.github.com> Co-authored-by: dylan-stitch <28106103+dylan-stitch@users.noreply.github.com> Co-authored-by: Dan Mosora <30501696+dmosorast@users.noreply.github.com> Co-authored-by: prijendev <prijen.khokhani@crestdatasys.com>
Description of change
Manual QA steps
Risks
Rollback steps