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-15362: Find better PK for poll_events #77

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ This tap:
**[poll_events](https://developers.pendo.io/docs/?bash#get-an-account-by-id)**

- Endpoint: [https://api/v1/aggregation](https://app.pendo.io/api/v1/aggregation)
- Primary key fields: `visitor_id`, `account_id`, `server`, `remote_ip`
- Primary key fields: `visitor_id`, `account_id`, `poll_id`, `browser_time`
- Replication strategy: INCREMENTAL (query filtered)
- Bookmark: `browserTime`
- Transformations: Camel to snake case.
Expand Down
2 changes: 1 addition & 1 deletion tap_pendo/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ def get_body(self, period, first):
class PollEvents(Stream):
replication_method = "INCREMENTAL"
name = "poll_events"
key_properties = ['visitor_id', 'account_id', 'server_name', 'remote_ip']
key_properties = ['visitor_id', 'account_id', 'poll_id', 'browser_time']

def __init__(self, config):
super().__init__(config=config)
Expand Down
2 changes: 1 addition & 1 deletion tests/tap_tester/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def expected_metadata(self):
self.REPLICATION_KEYS: {'browser_time'}
},
"poll_events":{
self.PRIMARY_KEYS: {"visitor_id", "account_id", "server_name", "remote_ip"},
self.PRIMARY_KEYS: {"visitor_id", "account_id", "poll_id", "browser_time"},
self.REPLICATION_METHOD: self.INCREMENTAL,
self.REPLICATION_KEYS: {'browser_time'}
},
Expand Down
19 changes: 19 additions & 0 deletions tests/unittests/test_poll_events_primary_key.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import unittest
from tap_pendo.streams import PollEvents

class TestPollEventsPrimaryKey(unittest.TestCase):

def test_poll_event_primary_key(self):
'''
Verify that primary keys for 'poll_events' stream
'''
# initialize config
config = {}
# expected primary key
expected_primary_keys = ['visitor_id', 'account_id', 'poll_id', 'browser_time']

# Initialize PollEvents object which sets primary keys
poll_events = PollEvents(config)

# verify the Primary Key
self.assertEqual(poll_events.key_properties, expected_primary_keys)