airbyte-cdk 6.41.3__py3-none-any.whl → 6.41.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airbyte_cdk/test/mock_http/mocker.py +13 -8
- {airbyte_cdk-6.41.3.dist-info → airbyte_cdk-6.41.4.dist-info}/METADATA +1 -1
- {airbyte_cdk-6.41.3.dist-info → airbyte_cdk-6.41.4.dist-info}/RECORD +7 -7
- {airbyte_cdk-6.41.3.dist-info → airbyte_cdk-6.41.4.dist-info}/LICENSE.txt +0 -0
- {airbyte_cdk-6.41.3.dist-info → airbyte_cdk-6.41.4.dist-info}/LICENSE_SHORT +0 -0
- {airbyte_cdk-6.41.3.dist-info → airbyte_cdk-6.41.4.dist-info}/WHEEL +0 -0
- {airbyte_cdk-6.41.3.dist-info → airbyte_cdk-6.41.4.dist-info}/entry_points.txt +0 -0
@@ -2,9 +2,10 @@
|
|
2
2
|
|
3
3
|
import contextlib
|
4
4
|
import functools
|
5
|
+
from collections import defaultdict
|
5
6
|
from enum import Enum
|
6
7
|
from types import TracebackType
|
7
|
-
from typing import Callable, List, Optional, Union
|
8
|
+
from typing import Callable, Dict, Iterable, List, Optional, Union
|
8
9
|
|
9
10
|
import requests_mock
|
10
11
|
|
@@ -40,7 +41,7 @@ class HttpMocker(contextlib.ContextDecorator):
|
|
40
41
|
|
41
42
|
def __init__(self) -> None:
|
42
43
|
self._mocker = requests_mock.Mocker()
|
43
|
-
self._matchers: List[HttpRequestMatcher] =
|
44
|
+
self._matchers: Dict[SupportedHttpMethods, List[HttpRequestMatcher]] = defaultdict(list)
|
44
45
|
|
45
46
|
def __enter__(self) -> "HttpMocker":
|
46
47
|
self._mocker.__enter__()
|
@@ -55,7 +56,7 @@ class HttpMocker(contextlib.ContextDecorator):
|
|
55
56
|
self._mocker.__exit__(exc_type, exc_val, exc_tb)
|
56
57
|
|
57
58
|
def _validate_all_matchers_called(self) -> None:
|
58
|
-
for matcher in self.
|
59
|
+
for matcher in self._get_matchers():
|
59
60
|
if not matcher.has_expected_match_count():
|
60
61
|
raise ValueError(f"Invalid number of matches for `{matcher}`")
|
61
62
|
|
@@ -69,9 +70,9 @@ class HttpMocker(contextlib.ContextDecorator):
|
|
69
70
|
responses = [responses]
|
70
71
|
|
71
72
|
matcher = HttpRequestMatcher(request, len(responses))
|
72
|
-
if matcher in self._matchers:
|
73
|
+
if matcher in self._matchers[method]:
|
73
74
|
raise ValueError(f"Request {matcher.request} already mocked")
|
74
|
-
self._matchers.append(matcher)
|
75
|
+
self._matchers[method].append(matcher)
|
75
76
|
|
76
77
|
getattr(self._mocker, method)(
|
77
78
|
requests_mock.ANY,
|
@@ -129,7 +130,7 @@ class HttpMocker(contextlib.ContextDecorator):
|
|
129
130
|
|
130
131
|
def assert_number_of_calls(self, request: HttpRequest, number_of_calls: int) -> None:
|
131
132
|
corresponding_matchers = list(
|
132
|
-
filter(lambda matcher: matcher.request
|
133
|
+
filter(lambda matcher: matcher.request is request, self._get_matchers())
|
133
134
|
)
|
134
135
|
if len(corresponding_matchers) != 1:
|
135
136
|
raise ValueError(
|
@@ -150,7 +151,7 @@ class HttpMocker(contextlib.ContextDecorator):
|
|
150
151
|
result = f(*args, **kwargs)
|
151
152
|
except requests_mock.NoMockAddress as no_mock_exception:
|
152
153
|
matchers_as_string = "\n\t".join(
|
153
|
-
map(lambda matcher: str(matcher.request), self.
|
154
|
+
map(lambda matcher: str(matcher.request), self._get_matchers())
|
154
155
|
)
|
155
156
|
raise ValueError(
|
156
157
|
f"No matcher matches {no_mock_exception.args[0]} with headers `{no_mock_exception.request.headers}` "
|
@@ -175,6 +176,10 @@ class HttpMocker(contextlib.ContextDecorator):
|
|
175
176
|
|
176
177
|
return wrapper
|
177
178
|
|
179
|
+
def _get_matchers(self) -> Iterable[HttpRequestMatcher]:
|
180
|
+
for matchers in self._matchers.values():
|
181
|
+
yield from matchers
|
182
|
+
|
178
183
|
def clear_all_matchers(self) -> None:
|
179
184
|
"""Clears all stored matchers by resetting the _matchers list to an empty state."""
|
180
|
-
self._matchers =
|
185
|
+
self._matchers = defaultdict(list)
|
@@ -331,7 +331,7 @@ airbyte_cdk/test/catalog_builder.py,sha256=-y05Cz1x0Dlk6oE9LSKhCozssV2gYBNtMdV5Y
|
|
331
331
|
airbyte_cdk/test/entrypoint_wrapper.py,sha256=9XBii_YguQp0d8cykn3hy102FsJcwIBQzSB7co5ho0s,9802
|
332
332
|
airbyte_cdk/test/mock_http/__init__.py,sha256=jE5kC6CQ0OXkTqKhciDnNVZHesBFVIA2YvkdFGwva7k,322
|
333
333
|
airbyte_cdk/test/mock_http/matcher.py,sha256=4Qj8UnJKZIs-eodshryce3SN1Ayc8GZpBETmP6hTEyc,1446
|
334
|
-
airbyte_cdk/test/mock_http/mocker.py,sha256=
|
334
|
+
airbyte_cdk/test/mock_http/mocker.py,sha256=XgsjMtVoeMpRELPyALgrkHFauH9H5irxrz1Kcxh2yFY,8013
|
335
335
|
airbyte_cdk/test/mock_http/request.py,sha256=tdB8cqk2vLgCDTOKffBKsM06llYs4ZecgtH6DKyx6yY,4112
|
336
336
|
airbyte_cdk/test/mock_http/response.py,sha256=s4-cQQqTtmeej0pQDWqmG0vUWpHS-93lIWMpW3zSVyU,662
|
337
337
|
airbyte_cdk/test/mock_http/response_builder.py,sha256=debPx_lRYBaQVSwCoKLa0F8KFk3h0qG7bWxFBATa0cc,7958
|
@@ -358,9 +358,9 @@ airbyte_cdk/utils/slice_hasher.py,sha256=EDxgROHDbfG-QKQb59m7h_7crN1tRiawdf5uU7G
|
|
358
358
|
airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
|
359
359
|
airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
|
360
360
|
airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
|
361
|
-
airbyte_cdk-6.41.
|
362
|
-
airbyte_cdk-6.41.
|
363
|
-
airbyte_cdk-6.41.
|
364
|
-
airbyte_cdk-6.41.
|
365
|
-
airbyte_cdk-6.41.
|
366
|
-
airbyte_cdk-6.41.
|
361
|
+
airbyte_cdk-6.41.4.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
|
362
|
+
airbyte_cdk-6.41.4.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
|
363
|
+
airbyte_cdk-6.41.4.dist-info/METADATA,sha256=B7iABwyr7lOJAzEREVt05ZO_3CFXhoEQX5zFdatD-As,6071
|
364
|
+
airbyte_cdk-6.41.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
365
|
+
airbyte_cdk-6.41.4.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
|
366
|
+
airbyte_cdk-6.41.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|