-
Notifications
You must be signed in to change notification settings - Fork 1
Generalize loader tests #32
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
Open
fordN
wants to merge
6
commits into
main
Choose a base branch
from
ford/generalize-loader-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
Foundational work to enable all loader tests to inherit common test patterns
Adds generalized streaming test infrastructure and migrates Redis and Snowflake loader tests to use the shared base classes.
Migrates the final three loader test suites to use the shared base test infrastructure
🎨 Ruff Formatting & Linting ReportRun the following commands locally to fix issues: ruff format .
ruff check . --fixFormatting changes needed:--- tests/integration/loaders/conftest.py
+++ tests/integration/loaders/conftest.py
@@ -141,11 +141,7 @@
loader_config = loader_config.copy()
# Only enable state if not explicitly configured
if 'state' not in loader_config:
- loader_config['state'] = {
- 'enabled': True,
- 'storage': 'memory',
- 'store_batch_id': True
- }
+ loader_config['state'] = {'enabled': True, 'storage': 'memory', 'store_batch_id': True}
# Create and return the loader instance
return self.config.loader_class(loader_config)
--- tests/integration/loaders/test_base_streaming.py
+++ tests/integration/loaders/test_base_streaming.py
@@ -138,7 +138,9 @@
reorg_response = ResponseBatch.reorg_batch(
invalidation_ranges=[BlockRange(network='ethereum', start=104, end=108)]
)
- reorg_results = list(loader.load_stream_continuous(iter([reorg_response]), test_table_name, connection_name='test_conn'))
+ reorg_results = list(
+ loader.load_stream_continuous(iter([reorg_response]), test_table_name, connection_name='test_conn')
+ )
assert len(reorg_results) == 1
assert reorg_results[0].success
@@ -174,7 +176,9 @@
)
# Load via streaming API (with connection_name for state tracking)
- results = list(loader.load_stream_continuous(iter([response]), test_table_name, connection_name='test_conn'))
+ results = list(
+ loader.load_stream_continuous(iter([response]), test_table_name, connection_name='test_conn')
+ )
assert len(results) == 1
assert results[0].success
@@ -187,7 +191,9 @@
reorg_response = ResponseBatch.reorg_batch(
invalidation_ranges=[BlockRange(network='ethereum', start=160, end=180)]
)
- reorg_results = list(loader.load_stream_continuous(iter([reorg_response]), test_table_name, connection_name='test_conn'))
+ reorg_results = list(
+ loader.load_stream_continuous(iter([reorg_response]), test_table_name, connection_name='test_conn')
+ )
assert len(reorg_results) == 1
assert reorg_results[0].success
@@ -248,7 +254,9 @@
reorg_response = ResponseBatch.reorg_batch(
invalidation_ranges=[BlockRange(network='ethereum', start=100, end=100)]
)
- reorg_results = list(loader.load_stream_continuous(iter([reorg_response]), test_table_name, connection_name='test_conn'))
+ reorg_results = list(
+ loader.load_stream_continuous(iter([reorg_response]), test_table_name, connection_name='test_conn')
+ )
assert len(reorg_results) == 1
assert reorg_results[0].success
2 files would be reformatted, 98 files already formattedLinting issues: |
31d82d2 to
1010d2a
Compare
1010d2a to
f910b03
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR creates a shared set of generalized integration tests that can be used across loader implementations. Previously each loader implemented their own integration test harnesses and tests, leading to huge amounts of code duplication and significant testing work for implementers of new loaders.
In this new setup with shared integration tests we have a set of shared base tests, shared streaming tests, and each loader/datastore just has to implement four functions on its destination data store in order to use these shared tests: get_row_count, query_rows, cleanup_table, and get_column_names. Loader implementers may also add loader specific tests for functionality specific to their loader implementation.
With these changes we significantly reduce the overall loader integration testing code and reduce the amount of code a loader dev has to write for integration tests of a new loader.
Summary:
Per-Loader Average