-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add ignore_stream_slicer_parameters_on_paginated_requests flag #35462
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
Changes from 4 commits
1913841
2d8f9be
ed2dd89
861f187
8da96e5
d8aa9d8
da4d26d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -273,6 +273,46 @@ def test_get_request_headers(test_name, paginator_mapping, expected_mapping): | |
pass | ||
|
||
|
||
@pytest.mark.parametrize( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my education: assuming this thing makes the test below run each time for each of the parameter tuples in the list, right? Neat. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is the |
||
"test_name, paginator_mapping, ignore_stream_slicer_parameters_on_paginated_requests, next_page_token, expected_mapping", | ||
[ | ||
("test_do_not_ignore_stream_slicer_params_if_ignore_is_true_but_no_next_page_token", {"key_from_pagination": "1000"}, True, None, {"key_from_pagination": "1000"}), | ||
("test_do_not_ignore_stream_slicer_params_if_ignore_is_false_and_no_next_page_token", {"key_from_pagination": "1000"}, False, None, {"key_from_pagination": "1000", "key_from_slicer": "value"}), | ||
("test_ignore_stream_slicer_params_on_paginated_request", {"key_from_pagination": "1000"}, True, {"page": 2}, {"key_from_pagination": "1000"}), | ||
("test_do_not_ignore_stream_slicer_params_on_paginated_request", {"key_from_pagination": "1000"}, False, {"page": 2}, {"key_from_pagination": "1000", "key_from_slicer": "value"}), | ||
], | ||
) | ||
def test_ignore_stream_slicer_parameters_on_paginated_requests(test_name, paginator_mapping, ignore_stream_slicer_parameters_on_paginated_requests, next_page_token, expected_mapping): | ||
# This test is separate from the other request options because request headers must be strings | ||
paginator = MagicMock() | ||
paginator.get_request_headers.return_value = paginator_mapping | ||
requester = MagicMock(use_cache=False) | ||
|
||
stream_slicer = MagicMock() | ||
stream_slicer.get_request_headers.return_value = {"key_from_slicer": "value"} | ||
|
||
record_selector = MagicMock() | ||
retriever = SimpleRetriever( | ||
name="stream_name", | ||
primary_key=primary_key, | ||
requester=requester, | ||
record_selector=record_selector, | ||
stream_slicer=stream_slicer, | ||
paginator=paginator, | ||
ignore_stream_slicer_parameters_on_paginated_requests=ignore_stream_slicer_parameters_on_paginated_requests, | ||
parameters={}, | ||
config={}, | ||
) | ||
|
||
request_option_type_to_method = { | ||
RequestOptionType.header: retriever._request_headers, | ||
} | ||
|
||
for _, method in request_option_type_to_method.items(): | ||
actual_mapping = method(None, None, next_page_token={"next_page_token": "1000"}) | ||
assert expected_mapping == actual_mapping | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"test_name, slicer_body_data, paginator_body_data, expected_body_data", | ||
[ | ||
|
Uh oh!
There was an error while loading. Please reload this page.