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-20155 Add missing tap tester #46

Merged
merged 10 commits into from Sep 6, 2022

Conversation

prijendev
Copy link
Contributor

Description of change

  • Added bookmark and automatic_fields test cases.
  • Added missing assertion in rest of the test cases.

Manual QA steps

Risks

Rollback steps

  • revert this branch

@prijendev prijendev changed the title Refactored tap tester test cases. TDL-20155 Add missing tap tester Aug 5, 2022
tests/base.py Outdated
BOOKMARK_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
INCREMENTAL = "INCREMENTAL"
FULL_TABLE = "FULL_TABLE"
ADITIONAL_AUTOMATIC = "aditional-automatic-fields"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ADITIONAL_AUTOMATIC = "aditional-automatic-fields"
ADDITIONAL_AUTOMATIC = "additional-automatic-fields"

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 this change is left to address.

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.


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

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.

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 dt_to_ts function to call with date-format.

@@ -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'}
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 the above streams removal from expected_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.

We are not going to skip these streams.

@@ -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

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

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 to validate unique values across all the pages instead of the first 2 pages.

"""Returns the connection properties"""
return {
"start_date" : "2018-08-21T00:00:00Z",
"accounts": "503491473,502890776",

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?

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 get_properties since we can pass multiple accounts in the env variable.

"accounts": "503491473,502890776",
"page_size": 100
}

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

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 test.

"accounts": os.getenv("TAP_LINKEDIN_ADS_ACCOUNTS"),
"page_size": 100
}

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

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 test.

Comment on lines 66 to 67
for stream, new_state in simulated_states.items():
new_states['bookmarks'][stream] = new_state
Copy link

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?

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 to directly assign dictionary, instead of looping through each stream.

"start_date" : self.START_DATE,
"accounts": "503491473,502890776",
}

Copy link

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?

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 test.

tests/base.py Outdated
Comment on lines 120 to 122
self.PRIMARY_KEYS: {'id'},
self.REPLICATION_METHOD: 'INCREMENTAL',
self.REPLICATION_METHOD: self.INCREMENTAL,
self.REPLICATION_KEYS: {'last_modified_time'}
Copy link
Contributor

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.

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 OBEY_START_DATE for the start_date test.

@@ -49,50 +68,51 @@ def test_run(self):
##########################################################################

print("REPLICATION START DATE CHANGE: {} ===>>> {} ".format(self.START_DATE, self.start_date_2))
Copy link
Contributor

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

Copy link
Contributor Author

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

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

Copy link
Contributor Author

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

@@ -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"}
Copy link
Contributor

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

Comment on lines 103 to 106
# 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)
Copy link
Contributor

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.

Copy link
Contributor

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.

Comment on lines 93 to 96
# 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()))

Copy link
Contributor

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.

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 this assertion.

@@ -2,6 +2,7 @@
from base import TestLinkedinAdsBase

class LinkedinAdsSyncTest(TestLinkedinAdsBase):
"""Test tap sync mode and metadata conforms to standards."""
Copy link
Contributor

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?

Copy link
Contributor Author

@prijendev prijendev Sep 2, 2022

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

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.

Copy link
Contributor Author

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>
@prijendev prijendev merged commit df28ff0 into crest-master Sep 6, 2022
@prijendev prijendev mentioned this pull request Sep 6, 2022
sgandhi1311 added a commit that referenced this pull request Oct 10, 2022
* 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>
nitingaikwad1 pushed a commit that referenced this pull request Feb 7, 2023
* 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>
sgandhi1311 added a commit that referenced this pull request Feb 7, 2023
* 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>
@dsprayberry dsprayberry deleted the TDL-20155-add-missing-tap-tester branch April 10, 2023 17:35
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.

None yet

6 participants