-
Notifications
You must be signed in to change notification settings - Fork 87
Add additional base test suite tests #140
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
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5f6e2b7
add mac to gitignore
7a176c3
change testing repo
3bcb1f4
adjust `start_date_2` for new repo
4a3d77a
add tap-tester automatic fields
08d0c2b
add tap-tester all fields
e06a630
add all expected streams to all fields test
ca2e4aa
set specific bookmark for test-repo
6394e3b
fix `collaborators` stream bookmark spelling for tap-tester
44796ee
add more streams to automatic fields test
f0fefdd
add tap-tester bookmarks
1d7635f
updates to automatic fields test:
c4129c4
omit `team_memberships` stream from `expected_check_streams`
b402944
build expected_check_streams() using expected_streams()
9a98a70
add bug id and description
2c1db59
pylint fixes:
2a081d6
adjust circle config:
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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -97,3 +97,8 @@ properties.json | |
|
|
||
| # Jetbrains IDE | ||
| .idea | ||
|
|
||
| # macOS | ||
| *.DS_Store | ||
| .AppleDouble | ||
| .LSOverride | ||
This file contains hidden or 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 hidden or 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 hidden or 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,75 @@ | ||
| import os | ||
|
|
||
| from tap_tester import runner, connections, menagerie | ||
|
|
||
| from base import TestGithubBase | ||
|
|
||
|
|
||
| class TestGithubAllFields(TestGithubBase): | ||
| """Test that with all fields selected for a stream automatic and available fields are replicated""" | ||
|
|
||
| @staticmethod | ||
| def name(): | ||
| return "tap_tester_github_all_fields" | ||
|
|
||
| def test_run(self): | ||
| """ | ||
| Ensure running the tap with all streams and fields selected results in the | ||
| replication of all fields. | ||
| - Verify no unexpected streams were replicated | ||
| - Verify that more than just the automatic fields are replicated for each stream. | ||
| """ | ||
|
|
||
| expected_streams = self.expected_streams() | ||
|
|
||
| # instantiate connection | ||
| conn_id = connections.ensure_connection(self) | ||
|
|
||
| # run check mode | ||
| 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('stream_name') in expected_streams] | ||
| self.perform_and_verify_table_and_field_selection( | ||
| conn_id, test_catalogs_all_fields, select_all_fields=True, | ||
| ) | ||
|
|
||
| # grab metadata after performing table-and-field selection to set expectations | ||
| stream_to_all_catalog_fields = dict() # used for asserting all fields are replicated | ||
| 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) | ||
|
|
||
| # run initial sync | ||
| 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): | ||
| # expected values | ||
| expected_automatic_keys = self.expected_primary_keys().get(stream) | ||
|
|
||
| # get all expected keys | ||
| expected_all_keys = stream_to_all_catalog_fields[stream] | ||
|
|
||
| # collect actual values | ||
| messages = synced_records.get(stream) | ||
| actual_all_keys = [set(message['data'].keys()) for message in messages['messages'] | ||
| if message['action'] == 'upsert'][0] | ||
|
|
||
| # Verify that you get some records for each stream | ||
| self.assertGreater(record_count_by_stream.get(stream, -1), 0) | ||
|
|
||
| # verify all fields for a stream were replicated | ||
| self.assertGreater(len(expected_all_keys), len(expected_automatic_keys)) | ||
| self.assertTrue(expected_automatic_keys.issubset(expected_all_keys), msg=f'{expected_automatic_keys-expected_all_keys} is not in "expected_all_keys"') | ||
| self.assertSetEqual(expected_all_keys, actual_all_keys) |
This file contains hidden or 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,72 @@ | ||
| """ | ||
| Test that with no fields selected for a stream automatic fields are still replicated | ||
| """ | ||
| from tap_tester import runner, connections | ||
|
|
||
| from base import TestGithubBase | ||
|
|
||
|
|
||
| class TestGithubAutomaticFields(TestGithubBase): | ||
| """Test that with no fields selected for a stream automatic fields are still replicated""" | ||
|
|
||
| @staticmethod | ||
| def name(): | ||
| return "tap_tester_github_automatic_fields" | ||
|
|
||
| def test_run(self): | ||
| """ | ||
| - Verify that for each stream you can get multiple pages of data | ||
| when no fields are selected. | ||
| - Verify that only the automatic fields are sent to the target. | ||
| - Verify that all replicated records have unique primary key values. | ||
| """ | ||
|
|
||
| # BUG TDL-16137 `team_memberships` stream is not passing run_and_verify_sync() | ||
| expected_streams = self.expected_check_streams() | ||
|
|
||
| # instantiate connection | ||
| conn_id = connections.ensure_connection(self) | ||
|
|
||
| # run check mode | ||
| found_catalogs = self.run_and_verify_check_mode(conn_id) | ||
|
|
||
| # table and field selection | ||
| test_catalogs_automatic_fields = [catalog for catalog in found_catalogs | ||
| if catalog.get('stream_name') in expected_streams] | ||
|
|
||
| self.perform_and_verify_table_and_field_selection( | ||
| conn_id, test_catalogs_automatic_fields, select_all_fields=False, | ||
| ) | ||
|
|
||
| # run initial sync | ||
| record_count_by_stream = self.run_and_verify_sync(conn_id) | ||
| synced_records = runner.get_records_from_target_output() | ||
|
|
||
| for stream in expected_streams: | ||
| with self.subTest(stream=stream): | ||
| # expected values | ||
| expected_keys = self.expected_primary_keys().get(stream) | ||
|
|
||
| # collect actual values | ||
| data = synced_records.get(stream, {}) | ||
| record_messages_keys = [set(row.get('data').keys()) for row in data.get('messages', {})] | ||
| primary_keys_list = [ | ||
| tuple(message.get('data').get(expected_pk) for expected_pk in expected_keys) | ||
| for message in data.get('messages') | ||
| if message.get('action') == 'upsert'] | ||
| unique_primary_keys_list = set(primary_keys_list) | ||
|
|
||
| # Verify that you get some records for each stream | ||
| self.assertGreater( | ||
| record_count_by_stream.get(stream, -1), 0, | ||
| msg="The number of records is not over the stream max limit for the {} stream".format(stream)) | ||
|
|
||
| # Verify that only the automatic fields are sent to the target | ||
| for actual_keys in record_messages_keys: | ||
| self.assertSetEqual(expected_keys, actual_keys) | ||
|
|
||
| # Verify that all replicated records have unique primary key values. | ||
| self.assertEqual( | ||
| len(primary_keys_list), | ||
| len(unique_primary_keys_list), | ||
| msg="Replicated record does not have unique primary key values.") | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.