Skip to content

Commit

Permalink
update generator to tuple of pk values (singer-io#137)
Browse files Browse the repository at this point in the history
* update generator to tuple of pk values
* pin pylint to 2.6.2
  • Loading branch information
HarrisonMarcRose authored Sep 1, 2021
1 parent 0021bce commit aaad1ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
extras_require={
'dev': [
'pylint',
'pylint==2.6.2',
'ipdb',
'nose',
]
Expand Down
25 changes: 13 additions & 12 deletions tests/test_github_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_run(self):

# table and field selection
test_catalogs = [catalog for catalog in found_catalogs
if catalog.get('stream_name') in expected_streams]
if catalog.get('stream_name') in expected_streams]

self.perform_and_verify_table_and_field_selection(conn_id, test_catalogs)

Expand All @@ -42,23 +42,24 @@ def test_run(self):
for stream in expected_streams:
with self.subTest(stream=stream):
# expected values
expected_primary_keys = self.expected_primary_keys()
expected_primary_keys = self.expected_primary_keys()[stream]

# collect information for assertions from syncs 1 & 2 base on expected values
record_count_sync = record_count_by_stream.get(stream, 0)
primary_keys_list = [(message.get('data').get(expected_pk) for expected_pk in expected_primary_keys)
for message in synced_records.get(stream).get('messages')
if message.get('action') == 'upsert']
primary_keys_list = [tuple(message.get('data').get(expected_pk)
for expected_pk in expected_primary_keys)
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
self.assertGreater(record_count_sync, page_size)

if record_count_sync > page_size:
primary_keys_list_1 = primary_keys_list[:page_size]
primary_keys_list_2 = primary_keys_list[page_size:2*page_size]
primary_keys_list_1 = primary_keys_list[:page_size]
primary_keys_list_2 = primary_keys_list[page_size:2*page_size]

primary_keys_page_1 = set(primary_keys_list_1)
primary_keys_page_2 = set(primary_keys_list_2)
primary_keys_page_1 = set(primary_keys_list_1)
primary_keys_page_2 = set(primary_keys_list_2)

# Verify by private keys that data is unique for page
self.assertTrue(primary_keys_page_1.isdisjoint(primary_keys_page_2))
# Verify by private keys that data is unique for page
self.assertEqual(len(primary_keys_page_1), page_size)
self.assertTrue(primary_keys_page_1.isdisjoint(primary_keys_page_2))

0 comments on commit aaad1ff

Please sign in to comment.