[low code connectors] fix bug where headers were not passed to cursor interpolation (#15347)
* fix bug where headers were not passed to cursor interpolation * add headers to error handler predicate
This commit is contained in:
@@ -119,6 +119,15 @@ SOME_BACKOFF_TIME = 60
|
||||
ResponseStatus.retry(10),
|
||||
None,
|
||||
),
|
||||
(
|
||||
"test_200_fail_with_predicate_from_header",
|
||||
HTTPStatus.OK,
|
||||
HttpResponseFilter(action=ResponseAction.FAIL, predicate="{{ headers['fail'] }}", options={}),
|
||||
None,
|
||||
{"fail": True},
|
||||
response_status.FAIL,
|
||||
None,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_default_error_handler(
|
||||
|
||||
@@ -20,8 +20,15 @@ from airbyte_cdk.sources.declarative.requesters.paginators.strategies.cursor_pag
|
||||
("test_token_from_response", "{{ response._metadata.content }}", None, "content_value"),
|
||||
("test_token_from_options", "{{ options.key }}", None, "value"),
|
||||
("test_token_not_found", "{{ response.invalid_key }}", None, None),
|
||||
("test_static_token_with_stop_condition_false", "token", InterpolatedBoolean(condition="{{False}}", options={}), "token"),
|
||||
("test_static_token_with_stop_condition_true", "token", InterpolatedBoolean(condition="{{True}}", options={}), None),
|
||||
("test_static_token_with_stop_condition_false", "token", InterpolatedBoolean("{{False}}", options={}), "token"),
|
||||
("test_static_token_with_stop_condition_true", "token", InterpolatedBoolean("{{True}}", options={}), None),
|
||||
("test_token_from_header", "{{ headers.next }}", InterpolatedBoolean("{{ not headers.has_more }}", options={}), "ready_to_go"),
|
||||
(
|
||||
"test_token_from_response_header_links",
|
||||
"{{ headers.link.next.url }}",
|
||||
InterpolatedBoolean("{{ not headers.link.next.url }}", options={}),
|
||||
"https://adventure.io/api/v1/records?page=2&per_page=100",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_cursor_pagination_strategy(test_name, template_string, stop_condition, expected_token):
|
||||
@@ -33,7 +40,8 @@ def test_cursor_pagination_strategy(test_name, template_string, stop_condition,
|
||||
)
|
||||
|
||||
response = requests.Response()
|
||||
response.headers = {"has_more": True}
|
||||
link_str = '<https://adventure.io/api/v1/records?page=2&per_page=100>; rel="next"'
|
||||
response.headers = {"has_more": True, "next": "ready_to_go", "link": link_str}
|
||||
response_body = {"_metadata": {"content": "content_value"}, "accounts": [], "end": 99, "total": 200, "characters": {}}
|
||||
response._content = json.dumps(response_body).encode("utf-8")
|
||||
last_records = [{"id": 0, "more_records": True}, {"id": 1, "more_records": True}]
|
||||
|
||||
Reference in New Issue
Block a user