Skip to content

Commit 138d78f

Browse files
Abel Milashclaude
andcommitted
Rename _HttpResponse to _AsyncResponse
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2d83148 commit 138d78f

6 files changed

Lines changed: 23 additions & 23 deletions

File tree

src/PowerPlatform/Dataverse/aio/core/_async_http.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from ...core._http_logger import _HttpLogger
2323

2424

25-
class _HttpResponse:
25+
class _AsyncResponse:
2626
"""Materialized HTTP response returned by :class:`_AsyncHttpClient._request`.
2727
2828
The body is fully buffered before this object is constructed, so all
@@ -88,14 +88,14 @@ def __init__(
8888
self._session = session
8989
self._logger = logger
9090

91-
async def _request(self, method: str, url: str, **kwargs: Any) -> _HttpResponse:
91+
async def _request(self, method: str, url: str, **kwargs: Any) -> _AsyncResponse:
9292
"""
9393
Execute an HTTP request asynchronously with automatic retry logic and timeout management.
9494
9595
Applies default timeouts based on HTTP method (120s for POST/DELETE, 10s for others)
9696
and retries on network errors with exponential backoff.
9797
98-
The response body is fully buffered and returned as a :class:`_HttpResponse` whose
98+
The response body is fully buffered and returned as a :class:`_AsyncResponse` whose
9999
accessors (``.text``, ``.json()``) are synchronous — no ``await`` required on the caller side.
100100
101101
:param method: HTTP method (GET, POST, PUT, DELETE, etc.).
@@ -105,7 +105,7 @@ async def _request(self, method: str, url: str, **kwargs: Any) -> _HttpResponse:
105105
:param kwargs: Additional arguments passed to ``aiohttp.ClientSession.request()``,
106106
including headers, data, etc.
107107
:return: Materialized HTTP response with body fully buffered.
108-
:rtype: :class:`_HttpResponse`
108+
:rtype: :class:`_AsyncResponse`
109109
:raises aiohttp.ClientError: If all retry attempts fail.
110110
:raises RuntimeError: If no session has been set.
111111
"""
@@ -144,7 +144,7 @@ async def _request(self, method: str, url: str, **kwargs: Any) -> _HttpResponse:
144144
t0 = time.monotonic()
145145
async with self._session.request(method, url, **kwargs) as resp:
146146
body = await resp.read()
147-
materialized = _HttpResponse(resp.status, dict(resp.headers), body)
147+
materialized = _AsyncResponse(resp.status, dict(resp.headers), body)
148148
elapsed_ms = (time.monotonic() - t0) * 1000
149149

150150
if self._logger is not None:

src/PowerPlatform/Dataverse/aio/data/_async_odata.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from urllib.parse import quote as _url_quote
1818

19-
from ..core._async_http import _AsyncHttpClient, _HttpResponse
19+
from ..core._async_http import _AsyncHttpClient, _AsyncResponse
2020
from ._async_upload import _AsyncFileUploadMixin
2121
from ._async_relationships import _AsyncRelationshipOperationsMixin
2222
from ...core.errors import *
@@ -107,7 +107,7 @@ async def _headers(self) -> Dict[str, str]:
107107
"User-Agent": ua,
108108
}
109109

110-
async def _raw_request(self, method: str, url: str, **kwargs) -> _HttpResponse:
110+
async def _raw_request(self, method: str, url: str, **kwargs) -> _AsyncResponse:
111111
return await self._http._request(method, url, **kwargs)
112112

113113
async def _request(
@@ -117,7 +117,7 @@ async def _request(
117117
*,
118118
expected: tuple[int, ...] = _DEFAULT_EXPECTED_STATUSES,
119119
**kwargs,
120-
) -> _HttpResponse:
120+
) -> _AsyncResponse:
121121
# Acquire base headers once (async), then use a sync closure for _RequestContext.build.
122122
# _RequestContext.build is a sync classmethod defined in _ODataBase and shared by both
123123
# sync and async clients — keeping it sync avoids duplicating the header-injection logic.
@@ -201,7 +201,7 @@ async def _execute_raw(
201201
req: _RawRequest,
202202
*,
203203
expected: tuple[int, ...] = _DEFAULT_EXPECTED_STATUSES,
204-
) -> _HttpResponse:
204+
) -> _AsyncResponse:
205205
"""Execute a ``_RawRequest`` and return the HTTP response.
206206
207207
Encodes the pre-serialised body (if present) as UTF-8 and merges any
@@ -985,7 +985,7 @@ async def _wait_for_attribute_visibility(
985985
f"after {total_wait} seconds (exhausted all retries)."
986986
) from last_error
987987

988-
async def _request_metadata_with_retry(self, method: str, url: str, **kwargs) -> _HttpResponse:
988+
async def _request_metadata_with_retry(self, method: str, url: str, **kwargs) -> _AsyncResponse:
989989
"""Fetch metadata with retries on transient errors."""
990990
max_attempts = 5
991991
backoff_seconds = 0.4

tests/unit/aio/core/test_async_http.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import aiohttp
88

9-
from PowerPlatform.Dataverse.aio.core._async_http import _AsyncHttpClient, _HttpResponse
9+
from PowerPlatform.Dataverse.aio.core._async_http import _AsyncHttpClient, _AsyncResponse
1010

1111

1212
def _make_resp(status: int = 200) -> MagicMock:
@@ -128,7 +128,7 @@ async def test_retries_on_client_error_and_succeeds(self):
128128
result = await client._request("get", "https://example.com/data")
129129

130130
assert session.request.call_count == 2
131-
assert isinstance(result, _HttpResponse)
131+
assert isinstance(result, _AsyncResponse)
132132
assert result.status == 200
133133

134134
async def test_raises_after_all_retries_exhausted(self):
@@ -178,7 +178,7 @@ async def test_retries_on_timeout_error(self):
178178
result = await client._request("get", "https://example.com/data")
179179

180180
assert session.request.call_count == 2
181-
assert isinstance(result, _HttpResponse)
181+
assert isinstance(result, _AsyncResponse)
182182
assert result.status == 200
183183

184184

tests/unit/aio/data/test_async_batch_internal.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99

1010
from PowerPlatform.Dataverse.aio.data._async_batch import _AsyncBatchClient
11-
from PowerPlatform.Dataverse.aio.core._async_http import _HttpResponse
11+
from PowerPlatform.Dataverse.aio.core._async_http import _AsyncResponse
1212
from PowerPlatform.Dataverse.core.errors import MetadataError, ValidationError
1313
from PowerPlatform.Dataverse.data._batch_base import (
1414
_RecordCreate,
@@ -628,37 +628,37 @@ async def test_not_found_raises(self):
628628

629629

630630
# ---------------------------------------------------------------------------
631-
# _HttpResponse
631+
# _AsyncResponse
632632
# ---------------------------------------------------------------------------
633633

634634

635635
class TestHttpResponse:
636-
"""Tests for _HttpResponse — the materialized response returned by _AsyncHttpClient."""
636+
"""Tests for _AsyncResponse — the materialized response returned by _AsyncHttpClient."""
637637

638638
def test_json_parses_body(self):
639639
"""json() parses the body bytes as JSON."""
640-
r = _HttpResponse(200, {"Content-Type": "application/json"}, b'{"value": []}')
640+
r = _AsyncResponse(200, {"Content-Type": "application/json"}, b'{"value": []}')
641641
assert r.json() == {"value": []}
642642

643643
def test_json_empty_body_returns_empty_dict(self):
644644
"""json() returns {} for an empty body."""
645-
r = _HttpResponse(200, {}, b"")
645+
r = _AsyncResponse(200, {}, b"")
646646
assert r.json() == {}
647647

648648
def test_status_and_status_code_equal(self):
649649
"""status and status_code are both set and equal."""
650-
r = _HttpResponse(207, {}, b"")
650+
r = _AsyncResponse(207, {}, b"")
651651
assert r.status == 207
652652
assert r.status_code == 207
653653

654654
def test_text_decodes_body(self):
655655
"""text property decodes body bytes as UTF-8."""
656-
r = _HttpResponse(200, {}, b"body text")
656+
r = _AsyncResponse(200, {}, b"body text")
657657
assert r.text == "body text"
658658

659659
def test_text_empty_body(self):
660660
"""text property returns empty string for empty body."""
661-
r = _HttpResponse(200, {}, b"")
661+
r = _AsyncResponse(200, {}, b"")
662662
assert r.text == ""
663663

664664

tests/unit/aio/data/test_async_odata_internal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _make_client() -> _AsyncODataClient:
2828

2929

3030
def _resp(json_data=None, status=200, headers=None):
31-
"""Create a mock _HttpResponse-compatible response."""
31+
"""Create a mock _AsyncResponse-compatible response."""
3232
r = MagicMock()
3333
r.status = status
3434
r.headers = headers or {}

tests/unit/aio/data/test_async_relationships.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _make_client() -> _AsyncODataClient:
3131

3232

3333
def _resp(json_data=None, status=200, headers=None):
34-
"""Create a mock _HttpResponse-compatible response."""
34+
"""Create a mock _AsyncResponse-compatible response."""
3535
r = MagicMock()
3636
r.status = status
3737
r.headers = headers or {}

0 commit comments

Comments
 (0)