airbyte-cdk 0.62.0__py3-none-any.whl → 0.62.1__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- airbyte_cdk/sources/connector_state_manager.py +5 -3
- airbyte_cdk/test/mock_http/mocker.py +3 -1
- airbyte_cdk/test/mock_http/response.py +9 -1
- {airbyte_cdk-0.62.0.dist-info → airbyte_cdk-0.62.1.dist-info}/METADATA +1 -1
- {airbyte_cdk-0.62.0.dist-info → airbyte_cdk-0.62.1.dist-info}/RECORD +9 -9
- unit_tests/test/mock_http/test_mocker.py +3 -1
- {airbyte_cdk-0.62.0.dist-info → airbyte_cdk-0.62.1.dist-info}/LICENSE.txt +0 -0
- {airbyte_cdk-0.62.0.dist-info → airbyte_cdk-0.62.1.dist-info}/WHEEL +0 -0
- {airbyte_cdk-0.62.0.dist-info → airbyte_cdk-0.62.1.dist-info}/top_level.txt +0 -0
@@ -38,7 +38,7 @@ class ConnectorStateManager:
|
|
38
38
|
|
39
39
|
def __init__(
|
40
40
|
self,
|
41
|
-
stream_instance_map: Mapping[str, AirbyteStream],
|
41
|
+
stream_instance_map: Mapping[str, Union[Stream, AirbyteStream]],
|
42
42
|
state: Optional[Union[List[AirbyteStateMessage], MutableMapping[str, Any]]] = None,
|
43
43
|
):
|
44
44
|
shared_state, per_stream_states = self._extract_from_state_message(state, stream_instance_map)
|
@@ -107,7 +107,9 @@ class ConnectorStateManager:
|
|
107
107
|
|
108
108
|
@classmethod
|
109
109
|
def _extract_from_state_message(
|
110
|
-
cls,
|
110
|
+
cls,
|
111
|
+
state: Optional[Union[List[AirbyteStateMessage], MutableMapping[str, Any]]],
|
112
|
+
stream_instance_map: Mapping[str, Union[Stream, AirbyteStream]],
|
111
113
|
) -> Tuple[Optional[AirbyteStateBlob], MutableMapping[HashableStreamDescriptor, Optional[AirbyteStateBlob]]]:
|
112
114
|
"""
|
113
115
|
Takes an incoming list of state messages or the legacy state format and extracts state attributes according to type
|
@@ -159,7 +161,7 @@ class ConnectorStateManager:
|
|
159
161
|
|
160
162
|
@staticmethod
|
161
163
|
def _create_descriptor_to_stream_state_mapping(
|
162
|
-
state: MutableMapping[str, Any], stream_to_instance_map: Mapping[str, Stream]
|
164
|
+
state: MutableMapping[str, Any], stream_to_instance_map: Mapping[str, Union[Stream, AirbyteStream]]
|
163
165
|
) -> MutableMapping[HashableStreamDescriptor, Optional[AirbyteStateBlob]]:
|
164
166
|
"""
|
165
167
|
Takes incoming state received in the legacy format and transforms it into a mapping of StreamDescriptor to AirbyteStreamState
|
@@ -60,7 +60,9 @@ class HttpMocker(contextlib.ContextDecorator):
|
|
60
60
|
getattr(self._mocker, method)(
|
61
61
|
requests_mock.ANY,
|
62
62
|
additional_matcher=self._matches_wrapper(matcher),
|
63
|
-
response_list=[
|
63
|
+
response_list=[
|
64
|
+
{"text": response.body, "status_code": response.status_code, "headers": response.headers} for response in responses
|
65
|
+
],
|
64
66
|
)
|
65
67
|
|
66
68
|
def get(self, request: HttpRequest, responses: Union[HttpResponse, List[HttpResponse]]) -> None:
|
@@ -1,10 +1,14 @@
|
|
1
1
|
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
2
2
|
|
3
|
+
from types import MappingProxyType
|
4
|
+
from typing import Mapping
|
5
|
+
|
3
6
|
|
4
7
|
class HttpResponse:
|
5
|
-
def __init__(self, body: str, status_code: int = 200):
|
8
|
+
def __init__(self, body: str, status_code: int = 200, headers: Mapping[str, str] = MappingProxyType({})):
|
6
9
|
self._body = body
|
7
10
|
self._status_code = status_code
|
11
|
+
self._headers = headers
|
8
12
|
|
9
13
|
@property
|
10
14
|
def body(self) -> str:
|
@@ -13,3 +17,7 @@ class HttpResponse:
|
|
13
17
|
@property
|
14
18
|
def status_code(self) -> int:
|
15
19
|
return self._status_code
|
20
|
+
|
21
|
+
@property
|
22
|
+
def headers(self) -> Mapping[str, str]:
|
23
|
+
return self._headers
|
@@ -26,7 +26,7 @@ airbyte_cdk/models/well_known_types.py,sha256=KKfNbow2gdLoC1Z4hcXy_JR8m_acsB2ol7
|
|
26
26
|
airbyte_cdk/sources/__init__.py,sha256=Ov7Uf03KPSZUmMZqZfUAK3tQwsdKjDQUDvTb-H0JyfA,1141
|
27
27
|
airbyte_cdk/sources/abstract_source.py,sha256=GSpNwbwJ0v-KvxWa0u_nWeC0r6G2fZNkpKUhXzf6YlI,14399
|
28
28
|
airbyte_cdk/sources/config.py,sha256=PYsY7y2u3EUwxLiEb96JnuKwH_E8CuxKggsRO2ZPSRc,856
|
29
|
-
airbyte_cdk/sources/connector_state_manager.py,sha256=
|
29
|
+
airbyte_cdk/sources/connector_state_manager.py,sha256=p9iwWbb5uqRbsrHsdZBMXKmyHgLVbsOcV3QQexBFnPE,11052
|
30
30
|
airbyte_cdk/sources/http_config.py,sha256=OBZeuyFilm6NlDlBhFQvHhTWabEvZww6OHDIlZujIS0,730
|
31
31
|
airbyte_cdk/sources/http_logger.py,sha256=v0kkpDtA0GUOgj6_3AayrYaBrSHBqG4t3MGbrtxaNmU,1437
|
32
32
|
airbyte_cdk/sources/source.py,sha256=dk50z8Roc28MJ8FxWe652B-GwItO__bTZqFm7WOtHnw,4412
|
@@ -253,9 +253,9 @@ airbyte_cdk/test/entrypoint_wrapper.py,sha256=uTOEYoWkYnbkooPJ4a4gZ-NEll5j1tTCAz
|
|
253
253
|
airbyte_cdk/test/state_builder.py,sha256=SlKadhKVi38ZSKMeceVAxjowxsDDT9vJoG6gU4zDrQE,705
|
254
254
|
airbyte_cdk/test/mock_http/__init__.py,sha256=uil6k-0NbUyDFZXtWw88HaS7r13i43VzA9H7hOHzZx8,322
|
255
255
|
airbyte_cdk/test/mock_http/matcher.py,sha256=J4C8g8PkdKo4OwHWMJGYJIyrLnQpXI5gXWUtyxsxHpM,1240
|
256
|
-
airbyte_cdk/test/mock_http/mocker.py,sha256=
|
256
|
+
airbyte_cdk/test/mock_http/mocker.py,sha256=Sb1Nnf3bVEJfiy5_IliRcyIiIPQL8esSWmm5j9u0E_E,6202
|
257
257
|
airbyte_cdk/test/mock_http/request.py,sha256=dd_i47FOGD5iRlU23daotv2gEn5NOVqTBAqykxdG6-0,3687
|
258
|
-
airbyte_cdk/test/mock_http/response.py,sha256=
|
258
|
+
airbyte_cdk/test/mock_http/response.py,sha256=F09QGG8N3Z8fL_b0rmSKTYoKgku5yZJQCpj0Fwwxu3s,588
|
259
259
|
airbyte_cdk/test/mock_http/response_builder.py,sha256=sc0lU_LN3wjBc4mFFV-3Y5IhYeapRdtB_-EDdHfyArA,7804
|
260
260
|
airbyte_cdk/utils/__init__.py,sha256=qZoNqzEKhIXdN_ZfvXlIGnmiDDjCFy6BVCzzWjUZcuU,294
|
261
261
|
airbyte_cdk/utils/airbyte_secrets_utils.py,sha256=q3aDl8T10ufGbeqnUPqbZLxQcHdkf2kDfQK_upWzBbI,2894
|
@@ -445,7 +445,7 @@ unit_tests/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
445
445
|
unit_tests/test/test_entrypoint_wrapper.py,sha256=m4csYvjO2PzvZZma7K322SBBiL5D33xuv8eUMjitDXE,10839
|
446
446
|
unit_tests/test/mock_http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
447
447
|
unit_tests/test/mock_http/test_matcher.py,sha256=dBndYzqvo3AdHRilLrqruXdPviwi91gWt-ubDsGb-yg,2327
|
448
|
-
unit_tests/test/mock_http/test_mocker.py,sha256=
|
448
|
+
unit_tests/test/mock_http/test_mocker.py,sha256=sOoWutnrPDKB99Y3bkEyr3HFELGivwuklVJ_ii8C-ew,8523
|
449
449
|
unit_tests/test/mock_http/test_request.py,sha256=O9ihefGNiZKpHqsGtis6BjF8VoaOULNR8zOblVqmsL4,7602
|
450
450
|
unit_tests/test/mock_http/test_response_builder.py,sha256=IxAww4gaOxG-9MW8kEZkRzYL2mO6xe4jIsxhi40i2ow,7878
|
451
451
|
unit_tests/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -456,8 +456,8 @@ unit_tests/utils/test_schema_inferrer.py,sha256=Z2jHBZ540wnYkylIdV_2xr75Vtwlxuyg
|
|
456
456
|
unit_tests/utils/test_secret_utils.py,sha256=XKe0f1RHYii8iwE6ATmBr5JGDI1pzzrnZUGdUSMJQP4,4886
|
457
457
|
unit_tests/utils/test_stream_status_utils.py,sha256=Xr8MZ2HWgTVIyMbywDvuYkRaUF4RZLQOT8-JjvcfR24,2970
|
458
458
|
unit_tests/utils/test_traced_exception.py,sha256=bDFP5zMBizFenz6V2WvEZTRCKGB5ijh3DBezjbfoYIs,4198
|
459
|
-
airbyte_cdk-0.62.
|
460
|
-
airbyte_cdk-0.62.
|
461
|
-
airbyte_cdk-0.62.
|
462
|
-
airbyte_cdk-0.62.
|
463
|
-
airbyte_cdk-0.62.
|
459
|
+
airbyte_cdk-0.62.1.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
|
460
|
+
airbyte_cdk-0.62.1.dist-info/METADATA,sha256=9m_kiUnGlScq9ANU1dhvx00D_p5inrTOtJ-09MkF1vo,11073
|
461
|
+
airbyte_cdk-0.62.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
462
|
+
airbyte_cdk-0.62.1.dist-info/top_level.txt,sha256=edvsDKTnE6sD2wfCUaeTfKf5gQIL6CPVMwVL2sWZzqo,51
|
463
|
+
airbyte_cdk-0.62.1.dist-info/RECORD,,
|
@@ -15,6 +15,7 @@ _ANOTHER_RESPONSE_BODY = "another body"
|
|
15
15
|
_A_RESPONSE = HttpResponse("any response")
|
16
16
|
_SOME_QUERY_PARAMS = {"q1": "query value"}
|
17
17
|
_SOME_HEADERS = {"h1": "header value"}
|
18
|
+
_OTHER_HEADERS = {"h2": "another header value"}
|
18
19
|
_SOME_REQUEST_BODY_MAPPING = {"first_field": "first_value", "second_field": 2}
|
19
20
|
_SOME_REQUEST_BODY_STR = "some_request_body"
|
20
21
|
|
@@ -24,13 +25,14 @@ class HttpMockerTest(TestCase):
|
|
24
25
|
def test_given_get_request_match_when_decorate_then_return_response(self, http_mocker):
|
25
26
|
http_mocker.get(
|
26
27
|
HttpRequest(_A_URL, _SOME_QUERY_PARAMS, _SOME_HEADERS),
|
27
|
-
HttpResponse(_A_RESPONSE_BODY, 474),
|
28
|
+
HttpResponse(_A_RESPONSE_BODY, 474, _OTHER_HEADERS),
|
28
29
|
)
|
29
30
|
|
30
31
|
response = requests.get(_A_URL, params=_SOME_QUERY_PARAMS, headers=_SOME_HEADERS)
|
31
32
|
|
32
33
|
assert response.text == _A_RESPONSE_BODY
|
33
34
|
assert response.status_code == 474
|
35
|
+
assert response.headers == _OTHER_HEADERS
|
34
36
|
|
35
37
|
@HttpMocker()
|
36
38
|
def test_given_loose_headers_matching_when_decorate_then_match(self, http_mocker):
|
File without changes
|
File without changes
|
File without changes
|