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-7596: Add tap-tester test for attribution window #169

Merged
merged 15 commits into from
Nov 19, 2021

Conversation

hpatel41
Copy link
Contributor

@hpatel41 hpatel41 commented Oct 7, 2021

Description of change

TDL-7596: Add tap-tester test for attribution window

  • Added test case for testing 7 day and 28 day attribution window.

NOTE: The UI does not allow the attribution window to be set except {1, 7, 28}. The tap is also working when we set an attribution window other than this.

Manual QA steps

Risks

Rollback steps

  • revert this branch

@hpatel41 hpatel41 changed the base branch from master to crest-master October 11, 2021 04:40
@hpatel41 hpatel41 marked this pull request as ready for review November 10, 2021 13:37
class FacebookAttributionWindow(FacebookBaseTest):

# set attribution window
attrubution_window = 7

Choose a reason for hiding this comment

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

Define constants in caps like ATTRIBUTION_WINDOW

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

def name():
return "tap_tester_facebook_attribution_window"

def get_properties(self, original: bool = True):

Choose a reason for hiding this comment

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

Why do we need this method here, isn't it defined 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.

Yes, it is defined, but here we wanted to use different values of attribution window.

Choose a reason for hiding this comment

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

Then can't we add one more optional parameter?

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, here only 1 argument can be passed in the function.

Choose a reason for hiding this comment

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

Okay

Copy link
Contributor

Choose a reason for hiding this comment

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

This is an unfortunate restriction of the tap-tester backend.

replication_key_value = record.get(replication_key)

# Verify the sync records respect the (simulated) start date value
self.assertGreaterEqual(self.parse_date(replication_key_value), self.parse_date(start_date_with_attribution_window),

Choose a reason for hiding this comment

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

@harshpatel4crest Can you please explain how does the 3 checks asked in the DoD of this ticket is accumulated in this test case?

Copy link
Contributor Author

@hpatel41 hpatel41 Nov 17, 2021

Choose a reason for hiding this comment

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

self.assertGreaterEqual(self.parse_date(replication_key_value), self.parse_date(start_date_with_attribution_window) is for the 1st check.

self.assertTrue(is_between, msg="No record found between start date and attribution date.") is for the 2nd check, where is_between is the boolean value for the checking if any record is present between the start date and buffered start date.

3rd check is about the error message when we pass the attribution window other than {1, 7, 28}. But the UI does not allow the attribution window to be set except {1, 7, 28}. The tap is also working when we set an attribution window other than this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please complete the 3rd assertion. If the tap does not throw an acceptable error, that is a bug and should be documented and linked in the test with a workaround.

Copy link
Contributor

Choose a reason for hiding this comment

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

Facebook only supports those values, so even though the tap does not blow up when given a different value I think we should force an error so that we match what they claim they support. Additionally we have use cases where the tap is ran directly so, just because the UI has restrictions around the values does not mean a user will not send something crazy into the config.

FB Docs: https://www.facebook.com/business/help/395050428485124?id=428636648170202

Stitch Docs: https://www.stitchdata.com/docs/integrations/saas/facebook-ads#select-attribution-window

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kspeer825 Added code change to raise an error when the attribution window is not 1, 7 or 28.

replication_key_value = record.get(replication_key)

# Verify the sync records respect the (simulated) start date value
self.assertGreaterEqual(self.parse_date(replication_key_value), self.parse_date(start_date_with_attribution_window),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please complete the 3rd assertion. If the tap does not throw an acceptable error, that is a bug and should be documented and linked in the test with a workaround.

replication_key_value = record.get(replication_key)

# Verify the sync records respect the (simulated) start date value
self.assertGreaterEqual(self.parse_date(replication_key_value), self.parse_date(start_date_with_attribution_window),
Copy link
Contributor

Choose a reason for hiding this comment

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

Facebook only supports those values, so even though the tap does not blow up when given a different value I think we should force an error so that we match what they claim they support. Additionally we have use cases where the tap is ran directly so, just because the UI has restrictions around the values does not mean a user will not send something crazy into the config.

FB Docs: https://www.facebook.com/business/help/395050428485124?id=428636648170202

Stitch Docs: https://www.stitchdata.com/docs/integrations/saas/facebook-ads#select-attribution-window

import unittest
import tap_facebook.__init__ as tap_facebook

class TestAttributionWindow(unittest.TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine to leave in this unittest, but this should be a tap-tester case. We want to prove the error is thrown during discovery.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kspeer825 Added integration test for verifying error is thrown in discovery mode.

@hpatel41 hpatel41 merged commit 923761b into crest-master Nov 19, 2021
@hpatel41 hpatel41 mentioned this pull request Nov 19, 2021
KrisPersonal pushed a commit that referenced this pull request Nov 19, 2021
* TDL-9728: Stream `ads_insights_age_gender` has unexpected datatype for replication key field `date_start` (#172)

* added format as date-time in schema file

* added code coverage

* added check for date format in the bookmark test

* added the check for first sync messages

Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>

* TDL-9809: `forced-replication-method` missing from metadata for some streams and TDL-9872: replication keys are not specified as expected in discoverable metadata	 (#167)

* added valid replication keys in catalog

* modified the code

* TDL-9809: Added replication keys in metadata

* adde code coverage

* Resolved review comments

Co-authored-by: harshpatel4_crest <harsh.patel4@crestdatasys.com>
Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>

* TDL-7455: Add tap-tester test to verify replication of deleted records	 (#168)

* TDL-7455: Added archived data integration test

* TDL-7455: Updated integration test

* added code coverage

* Resolved review comment

Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>

* TDL-7596: Add tap-tester test for attribution window (#169)

* added tap tester test for attribution window

* updated the code

* added code coverage

* updated the code according to the comments

* updated code to raise error when attribution window is not 1, 7, 28

* test: run invalid attribution window intergation test

* updated test case

* test: updated test case code

* test: test invalid attribution window

* test: test invalid attribution window

* test: test invalid attribution window

* test: test invalid attribution window

* test: run invalid attribution window test case

* added intergation test for invalid sttribution window

Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>

Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>
Co-authored-by: savan-chovatiya <80703490+savan-chovatiya@users.noreply.github.com>
jesuejunior pushed a commit to sixcodes/tap-facebook that referenced this pull request Mar 17, 2023
* TDL-9728: Stream `ads_insights_age_gender` has unexpected datatype for replication key field `date_start` (singer-io#172)

* added format as date-time in schema file

* added code coverage

* added check for date format in the bookmark test

* added the check for first sync messages

Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>

* TDL-9809: `forced-replication-method` missing from metadata for some streams and TDL-9872: replication keys are not specified as expected in discoverable metadata	 (singer-io#167)

* added valid replication keys in catalog

* modified the code

* TDL-9809: Added replication keys in metadata

* adde code coverage

* Resolved review comments

Co-authored-by: harshpatel4_crest <harsh.patel4@crestdatasys.com>
Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>

* TDL-7455: Add tap-tester test to verify replication of deleted records	 (singer-io#168)

* TDL-7455: Added archived data integration test

* TDL-7455: Updated integration test

* added code coverage

* Resolved review comment

Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>

* TDL-7596: Add tap-tester test for attribution window (singer-io#169)

* added tap tester test for attribution window

* updated the code

* added code coverage

* updated the code according to the comments

* updated code to raise error when attribution window is not 1, 7, 28

* test: run invalid attribution window intergation test

* updated test case

* test: updated test case code

* test: test invalid attribution window

* test: test invalid attribution window

* test: test invalid attribution window

* test: test invalid attribution window

* test: run invalid attribution window test case

* added intergation test for invalid sttribution window

Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>

Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com>
Co-authored-by: savan-chovatiya <80703490+savan-chovatiya@users.noreply.github.com>
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