Skip to content

Commit dcc8028

Browse files
olivermeyerclaude
andcommitted
refactor(test): extract constant for httpx patch path
Replace 9 inline occurrences of the patch target string "aignostics.platform._service.httpx.AsyncClient" with a single module-level constant _PATCH_HTTPX_ASYNC_CLIENT, following the existing _PATCH_AUTH_GETTER convention. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4e3c1de commit dcc8028

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

tests/aignostics/platform/service_test.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from aignostics.utils import Health
1010

1111
_PATCH_AUTH_GETTER = "aignostics.platform._service.get_token"
12+
_PATCH_HTTPX_ASYNC_CLIENT = "aignostics.platform._service.httpx.AsyncClient"
1213

1314

1415
@pytest.mark.unit
@@ -22,7 +23,7 @@ async def test_determine_api_authenticated_health_success() -> None:
2223
mock_client.get.return_value = mock_response
2324

2425
with (
25-
patch("aignostics.platform._service.httpx.AsyncClient") as mock_cls,
26+
patch(_PATCH_HTTPX_ASYNC_CLIENT) as mock_cls,
2627
patch(_PATCH_AUTH_GETTER, return_value="test-token"),
2728
):
2829
mock_cls.return_value.__aenter__ = AsyncMock(return_value=mock_client)
@@ -42,7 +43,7 @@ async def test_determine_api_authenticated_health_non_200() -> None:
4243
mock_client.get.return_value = mock_response
4344

4445
with (
45-
patch("aignostics.platform._service.httpx.AsyncClient") as mock_cls,
46+
patch(_PATCH_HTTPX_ASYNC_CLIENT) as mock_cls,
4647
patch(_PATCH_AUTH_GETTER, return_value="test-token"),
4748
):
4849
mock_cls.return_value.__aenter__ = AsyncMock(return_value=mock_client)
@@ -72,7 +73,7 @@ async def test_determine_api_public_health_non_200() -> None:
7273
mock_client = AsyncMock()
7374
mock_client.get.return_value = mock_response
7475

75-
with patch("aignostics.platform._service.httpx.AsyncClient") as mock_cls:
76+
with patch(_PATCH_HTTPX_ASYNC_CLIENT) as mock_cls:
7677
mock_cls.return_value.__aenter__ = AsyncMock(return_value=mock_client)
7778
mock_cls.return_value.__aexit__ = AsyncMock(return_value=None)
7879
result = await Service()._determine_api_public_health()
@@ -87,7 +88,7 @@ async def test_determine_api_public_health_handles_exception() -> None:
8788
mock_client = AsyncMock()
8889
mock_client.get.side_effect = ConnectionError("unreachable")
8990

90-
with patch("aignostics.platform._service.httpx.AsyncClient") as mock_cls:
91+
with patch(_PATCH_HTTPX_ASYNC_CLIENT) as mock_cls:
9192
mock_cls.return_value.__aenter__ = AsyncMock(return_value=mock_client)
9293
mock_cls.return_value.__aexit__ = AsyncMock(return_value=None)
9394
result = await Service()._determine_api_public_health()
@@ -106,7 +107,7 @@ async def test_determine_api_public_health_up_response() -> None:
106107
mock_client = AsyncMock()
107108
mock_client.get.return_value = mock_response
108109

109-
with patch("aignostics.platform._service.httpx.AsyncClient") as mock_cls:
110+
with patch(_PATCH_HTTPX_ASYNC_CLIENT) as mock_cls:
110111
mock_cls.return_value.__aenter__ = AsyncMock(return_value=mock_client)
111112
mock_cls.return_value.__aexit__ = AsyncMock(return_value=None)
112113
result = await Service()._determine_api_public_health()
@@ -124,7 +125,7 @@ async def test_determine_api_public_health_degraded_response() -> None:
124125
mock_client = AsyncMock()
125126
mock_client.get.return_value = mock_response
126127

127-
with patch("aignostics.platform._service.httpx.AsyncClient") as mock_cls:
128+
with patch(_PATCH_HTTPX_ASYNC_CLIENT) as mock_cls:
128129
mock_cls.return_value.__aenter__ = AsyncMock(return_value=mock_client)
129130
mock_cls.return_value.__aexit__ = AsyncMock(return_value=None)
130131
result = await Service()._determine_api_public_health()
@@ -143,7 +144,7 @@ async def test_determine_api_public_health_degraded_response_with_reason() -> No
143144
mock_client = AsyncMock()
144145
mock_client.get.return_value = mock_response
145146

146-
with patch("aignostics.platform._service.httpx.AsyncClient") as mock_cls:
147+
with patch(_PATCH_HTTPX_ASYNC_CLIENT) as mock_cls:
147148
mock_cls.return_value.__aenter__ = AsyncMock(return_value=mock_client)
148149
mock_cls.return_value.__aexit__ = AsyncMock(return_value=None)
149150
result = await Service()._determine_api_public_health()
@@ -162,7 +163,7 @@ async def test_determine_api_public_health_unknown_status_is_down() -> None:
162163
mock_client = AsyncMock()
163164
mock_client.get.return_value = mock_response
164165

165-
with patch("aignostics.platform._service.httpx.AsyncClient") as mock_cls:
166+
with patch(_PATCH_HTTPX_ASYNC_CLIENT) as mock_cls:
166167
mock_cls.return_value.__aenter__ = AsyncMock(return_value=mock_client)
167168
mock_cls.return_value.__aexit__ = AsyncMock(return_value=None)
168169
result = await Service()._determine_api_public_health()
@@ -182,7 +183,7 @@ async def test_determine_api_authenticated_health_degraded_response() -> None:
182183
mock_client.get.return_value = mock_response
183184

184185
with (
185-
patch("aignostics.platform._service.httpx.AsyncClient") as mock_cls,
186+
patch(_PATCH_HTTPX_ASYNC_CLIENT) as mock_cls,
186187
patch(_PATCH_AUTH_GETTER, return_value="test-token"),
187188
):
188189
mock_cls.return_value.__aenter__ = AsyncMock(return_value=mock_client)

0 commit comments

Comments
 (0)