Skip to content

Commit 51434f2

Browse files
committed
renamed the adapter methods
1 parent 06efbf1 commit 51434f2

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

apimatic_core/adapters/request_adapter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def _from_django(req: DjangoRequestLike) -> Request:
159159
# Public API
160160
# -----------------------
161161

162-
async def to_unified_request(
162+
async def to_unified_request_async(
163163
req: Union[StarletteRequestLike, FlaskRequestLike, DjangoRequestLike]
164164
) -> Request:
165165
"""
@@ -177,12 +177,12 @@ async def to_unified_request(
177177
raise TypeError(f"Unsupported request type: {type(req)!r}")
178178

179179

180-
def to_unified_request_sync(
180+
def to_unified_request(
181181
req: Union[StarletteRequestLike, FlaskRequestLike, DjangoRequestLike, Any]
182182
) -> Request:
183183
"""
184184
Synchronous wrapper around `to_unified_request` with LocalProxy unwrapping.
185185
"""
186186
unwrapped = _unwrap_local_proxy(req)
187187
# We expect to be called from sync code; create and run a fresh loop.
188-
return asyncio.run(to_unified_request(unwrapped))
188+
return asyncio.run(to_unified_request_async(unwrapped))

tests/apimatic_core/adapters/test_request_adapter.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from apimatic_core_interfaces.http.request import Request
44

55
from apimatic_core.adapters.request_adapter import (
6-
to_unified_request, # async core
7-
to_unified_request_sync, # sync wrapper
6+
to_unified_request_async, # async core
7+
to_unified_request, # sync wrapper
88
_as_listdict, # helper (public in module)
99
)
1010

@@ -187,7 +187,7 @@ def test_starlette_non_form_skips_form_and_snapshots_body(self):
187187
cookies={"sid": "abc"},
188188
formdata=FormDataStarletteLike({"ignored": ["x"]}),
189189
)
190-
snap: Request = asyncio.run(to_unified_request(req))
190+
snap: Request = asyncio.run(to_unified_request_async(req))
191191
assert snap.method == "GET"
192192
assert snap.path == "/fast-json/42"
193193
assert snap.url == "https://ex.com/fast-json/42?q=ok"
@@ -211,7 +211,7 @@ def test_starlette_form_multipart_parses_text_and_ignores_files(self):
211211
cookies={"c": "1"},
212212
formdata=form,
213213
)
214-
snap: Request = asyncio.run(to_unified_request(req))
214+
snap: Request = asyncio.run(to_unified_request_async(req))
215215
assert snap.method == "POST"
216216
assert snap.path == "/fast-mp/9"
217217
assert snap.query == {"z": ["ok"]}
@@ -234,7 +234,7 @@ def test_starlette_form_urlencoded_parses_scalars_and_lists(self):
234234
cookies={"c": "2"},
235235
formdata=form,
236236
)
237-
snap: Request = asyncio.run(to_unified_request(req))
237+
snap: Request = asyncio.run(to_unified_request_async(req))
238238
assert snap.method == "POST"
239239
assert snap.path == "/fast-form/1"
240240
assert snap.query == {"x": ["1"]}
@@ -257,7 +257,7 @@ def test_flask_basic_and_cookie_header_fallback(self):
257257
cookies={}, # force header fallback
258258
form=form,
259259
)
260-
snap: Request = to_unified_request_sync(req)
260+
snap: Request = to_unified_request(req)
261261
assert snap.method == "POST"
262262
assert snap.path == "/flask-form/5"
263263
assert snap.url.endswith("/flask-form/5?q=x&q=y")
@@ -279,7 +279,7 @@ def test_flask_uses_cookie_jar_when_present_no_header_needed(self):
279279
cookies={"sid": "JAR"},
280280
form=MultiDictStub({}),
281281
)
282-
snap: Request = to_unified_request_sync(req)
282+
snap: Request = to_unified_request(req)
283283
assert snap.cookies == {"sid": "JAR"} # header fallback not used
284284

285285
# ------- Django branch -------
@@ -297,7 +297,7 @@ def test_django_headers_meta_fallback_and_basic_mapping(self):
297297
POST=MultiDictStub({"a": "1", "b": "2"}),
298298
absolute="http://testserver/django-form/7?x=1&x=2",
299299
)
300-
snap: Request = to_unified_request_sync(req)
300+
snap: Request = to_unified_request(req)
301301
assert snap.method == "POST"
302302
assert snap.path == "/django-form/7"
303303
assert snap.url.startswith("http://testserver/django-form/7?")
@@ -319,7 +319,7 @@ def test_django_headers_present_no_meta_fallback(self):
319319
POST=MultiDictStub({}),
320320
absolute="http://testserver/h?p=1",
321321
)
322-
snap: Request = to_unified_request_sync(req)
322+
snap: Request = to_unified_request(req)
323323
assert snap.headers == {"X-Direct": "yes"} # no META fallback used
324324

325325
# ------- Sync wrapper LocalProxy unwrapping -------
@@ -336,7 +336,7 @@ def test_sync_wrapper_unwraps_localproxy_duck_type(self):
336336
absolute="http://testserver/p?q=ok",
337337
)
338338
proxy = LocalProxyLike(inner)
339-
snap: Request = to_unified_request_sync(proxy)
339+
snap: Request = to_unified_request(proxy)
340340
assert snap.method == "GET"
341341
assert snap.path == "/p"
342342
assert snap.query == {"q": ["ok"]}
@@ -356,7 +356,7 @@ def test_sync_wrapper_unwrap_localproxy_raises_and_uses_original_object(self):
356356
POST=MultiDictStub({}),
357357
absolute="http://testserver/ex?q=ok",
358358
)
359-
snap = to_unified_request_sync(proxy)
359+
snap = to_unified_request(proxy)
360360
assert snap.method == "GET"
361361
assert snap.path == "/ex"
362362
assert snap.query == {"q": ["ok"]}
@@ -374,7 +374,7 @@ def test_sync_wrapper_plain_object_pass_through(self):
374374
POST=MultiDictStub({}),
375375
absolute="http://testserver/plain",
376376
)
377-
snap = to_unified_request_sync(req)
377+
snap = to_unified_request(req)
378378
assert snap.path == "/plain"
379379
assert snap.headers == {"A": "B"}
380380

@@ -384,7 +384,7 @@ def test_async_adapter_rejects_unsupported_type(self):
384384
class Unknown:
385385
pass
386386
with pytest.raises(TypeError):
387-
asyncio.run(to_unified_request(Unknown()))
387+
asyncio.run(to_unified_request_async(Unknown()))
388388

389389
# ------- _as_listdict coverage -------
390390

0 commit comments

Comments
 (0)