-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add pagination visitors stream #129
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
abea113
add custom pagination support for Visitors stream
45b8b2e
update unittests
e716b27
fix the vistors filter value
bde2cc7
- fix minor pagination issue
39235a1
fix test name and start date
adc1e55
fix the review
2559c58
fix regression
dd54ff0
fix lint
8a2a4e6
update start date to reduce the execution time and minor refoctoring
ed72fba
setup and changelog update
sgandhi1311 e927287
remove unused debug statement
sgandhi1311 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import tap_tester.connections as connections | ||
import tap_tester.menagerie as menagerie | ||
import tap_tester.runner as runner | ||
from base import TestPendoBase | ||
|
||
|
||
class PendoAllFieldsTest(TestPendoBase): | ||
start_date = "2019-09-10T00:00:00Z" | ||
record_limit = 50 | ||
include_anonymous_visitors = False | ||
def name(self): | ||
return "pendo_all_fields_test" | ||
|
||
def get_properties(self, original: bool = True): | ||
"""Configuration properties required for the tap.""" | ||
return { | ||
# To reduce the execution time to test this stream taking recently start_date | ||
"start_date": self.start_date, | ||
"lookback_window": "1", | ||
"period": "dayRange", | ||
"record_limit": self.record_limit, | ||
"include_anonymous_visitors": self.include_anonymous_visitors | ||
} | ||
|
||
def test_run(self): | ||
# Verify that visitors pagination logic work as expected named and anonymous visitors | ||
# Note: there are 21000+ named and anonymous visitors | ||
self.run_pagination_test(expected_streams= {"visitors"}, | ||
start_date="2019-09-10T00:00:00Z", | ||
record_limit=10000, | ||
include_anonymous_visitors="true") | ||
|
||
# Verify with visitors pagination, we are able to sync child stream records i.e. visitor_history | ||
# Note: there are only 58 named and anonymous visitors but only recently updated visitors will be synced | ||
self.run_pagination_test(expected_streams={"visitors", "visitor_history"}, | ||
start_date=self.START_DATE_VISTOR_HISTORY, | ||
record_limit=50, | ||
include_anonymous_visitors="false") | ||
|
||
|
||
def run_pagination_test(self, expected_streams, start_date, record_limit, include_anonymous_visitors): | ||
""" | ||
This is a canary test to verify pagination implementation for the Visitors stream. | ||
""" | ||
self.streams_to_test = expected_streams | ||
self.start_date = start_date | ||
self.record_limit = record_limit | ||
self.include_anonymous_visitors = include_anonymous_visitors | ||
|
||
conn_id = connections.ensure_connection(self) | ||
|
||
found_catalogs = self.run_and_verify_check_mode(conn_id) | ||
|
||
# table and field selection | ||
test_catalogs_all_fields = [catalog for catalog in found_catalogs | ||
if catalog.get('tap_stream_id') in expected_streams] | ||
|
||
self.perform_and_verify_table_and_field_selection( | ||
conn_id, test_catalogs_all_fields) | ||
|
||
# Grab metadata after performing table-and-field selection to set expectations | ||
# used for asserting all fields are replicated | ||
stream_to_all_catalog_fields = dict() | ||
for catalog in test_catalogs_all_fields: | ||
stream_id, stream_name = catalog['stream_id'], catalog['stream_name'] | ||
catalog_entry = menagerie.get_annotated_schema(conn_id, stream_id) | ||
fields_from_field_level_md = [md_entry['breadcrumb'][1] | ||
for md_entry in catalog_entry['metadata'] | ||
if md_entry['breadcrumb'] != []] | ||
stream_to_all_catalog_fields[stream_name] = set( | ||
fields_from_field_level_md) | ||
|
||
record_count_by_stream = self.run_and_verify_sync(conn_id) | ||
|
||
synced_records = runner.get_records_from_target_output() | ||
|
||
# Verify no unexpected streams were replicated | ||
synced_stream_names = set(synced_records.keys()) | ||
|
||
self.assertSetEqual(expected_streams, synced_stream_names) | ||
for stream in expected_streams: | ||
with self.subTest(stream=stream): | ||
self.assertGreaterEqual(record_count_by_stream.get(stream), 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 strongly suggest not following this approach as it creates inverted dependancy, this function belongs to the generic implementation of the stream class, and this condition refers to the name of a child class.
i would suggest that you modify this method in the
Visitors
class belowThere 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.
or you can convert this into a generic implementation