Skip to content

Commit 5b3fd2c

Browse files
adamtheturtleclaude
andcommitted
Remove future annotations, add HTTPXTransport tests
Remove `from __future__ import annotations` from transports.py. Add tests for HTTPXTransport covering both float and tuple timeout branches to achieve 100% coverage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c6c313b commit 5b3fd2c

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

src/vws/transports.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""HTTP transport implementations for VWS clients."""
22

3-
from __future__ import annotations
4-
53
from typing import Protocol, runtime_checkable
64

75
import httpx

tests/test_transports.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"""Tests for HTTP transport implementations."""
2+
3+
from http import HTTPStatus
4+
5+
import httpx
6+
import respx
7+
8+
from vws.response import Response
9+
from vws.transports import HTTPXTransport
10+
11+
12+
class TestHTTPXTransport:
13+
"""Tests for ``HTTPXTransport``."""
14+
15+
@respx.mock
16+
def test_float_timeout(self) -> None:
17+
"""``HTTPXTransport`` works with a float timeout."""
18+
respx.post(url="https://example.com/test").mock(
19+
return_value=httpx.Response(
20+
status_code=HTTPStatus.OK,
21+
text="OK",
22+
),
23+
)
24+
transport = HTTPXTransport()
25+
response = transport(
26+
method="POST",
27+
url="https://example.com/test",
28+
headers={"Content-Type": "text/plain"},
29+
data=b"hello",
30+
timeout=30.0,
31+
)
32+
assert isinstance(response, Response)
33+
assert response.status_code == HTTPStatus.OK
34+
assert response.text == "OK"
35+
assert response.tell_position == 0
36+
37+
@respx.mock
38+
def test_tuple_timeout(self) -> None:
39+
"""``HTTPXTransport`` works with a (connect, read) timeout
40+
tuple.
41+
"""
42+
respx.post(url="https://example.com/test").mock(
43+
return_value=httpx.Response(
44+
status_code=HTTPStatus.OK,
45+
text="OK",
46+
),
47+
)
48+
transport = HTTPXTransport()
49+
response = transport(
50+
method="POST",
51+
url="https://example.com/test",
52+
headers={"Content-Type": "text/plain"},
53+
data=b"hello",
54+
timeout=(5.0, 30.0),
55+
)
56+
assert isinstance(response, Response)
57+
assert response.status_code == HTTPStatus.OK

0 commit comments

Comments
 (0)