Skip to content
Prev Previous commit
Next Next commit
Regenerate sync tests with unasync
  • Loading branch information
zanieb committed May 10, 2023
commit f0d3acd02288f8b47252452ed41b9bcad1056674
17 changes: 15 additions & 2 deletions tests/_sync/test_http2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from httpcore.backends.mock import MockStream



def test_http2_connection():
origin = Origin(b"https", b"example.com", 443)
stream = MockStream(
Expand All @@ -31,7 +32,9 @@ def test_http2_connection():
).serialize(),
]
)
with HTTP2Connection(origin=origin, stream=stream, keepalive_expiry=5.0) as conn:
with HTTP2Connection(
origin=origin, stream=stream, keepalive_expiry=5.0
) as conn:
response = conn.request("GET", "https://example.com/")
assert response.status == 200
assert response.content == b"Hello, world!"
Expand Down Expand Up @@ -71,7 +74,9 @@ def test_http2_connection_closed():
hyperframe.frame.GoAwayFrame(stream_id=0, error_code=0).serialize(),
]
)
with HTTP2Connection(origin=origin, stream=stream, keepalive_expiry=5.0) as conn:
with HTTP2Connection(
origin=origin, stream=stream, keepalive_expiry=5.0
) as conn:
conn.request("GET", "https://example.com/")

with pytest.raises(RemoteProtocolError):
Expand All @@ -80,6 +85,7 @@ def test_http2_connection_closed():
assert not conn.is_available()



def test_http2_connection_post_request():
origin = Origin(b"https", b"example.com", 443)
stream = MockStream(
Expand Down Expand Up @@ -111,6 +117,7 @@ def test_http2_connection_post_request():
assert response.content == b"Hello, world!"



def test_http2_connection_with_remote_protocol_error():
"""
If a remote protocol error occurs, then no response will be returned,
Expand All @@ -123,6 +130,7 @@ def test_http2_connection_with_remote_protocol_error():
conn.request("GET", "https://example.com/")



def test_http2_connection_with_rst_stream():
"""
If a stream reset occurs, then no response will be returned,
Expand Down Expand Up @@ -168,6 +176,7 @@ def test_http2_connection_with_rst_stream():
assert response.status == 200



def test_http2_connection_with_goaway():
"""
If a stream reset occurs, then no response will be returned,
Expand Down Expand Up @@ -213,6 +222,7 @@ def test_http2_connection_with_goaway():
conn.request("GET", "https://example.com/")



def test_http2_connection_with_flow_control():
origin = Origin(b"https", b"example.com", 443)
stream = MockStream(
Expand Down Expand Up @@ -272,6 +282,7 @@ def test_http2_connection_with_flow_control():
assert response.content == b"100,000 bytes received"



def test_http2_connection_attempt_close():
"""
A connection can only be closed when it is idle.
Expand Down Expand Up @@ -306,6 +317,7 @@ def test_http2_connection_attempt_close():
conn.request("GET", "https://example.com/")



def test_http2_request_to_incorrect_origin():
"""
A connection can only send requests to whichever origin it is connected to.
Expand All @@ -317,6 +329,7 @@ def test_http2_request_to_incorrect_origin():
conn.request("GET", "https://other.com/")



def test_http2_remote_max_streams_update():
"""
If the remote server updates the maximum concurrent streams value, we should
Expand Down