Skip to content

Commit

Permalink
Update unittest to use protocol fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
kristjanvalur committed Dec 3, 2023
1 parent 194f32d commit 435e6dc
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions tests/protocols/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,10 +1013,11 @@ async def websocket_session(url):


@pytest.mark.anyio
@pytest.mark.parametrize("ws_protocol_cls", WS_PROTOCOLS)
@pytest.mark.parametrize("http_protocol_cls", HTTP_PROTOCOLS)
async def test_server_reject_connection_with_response(
ws_protocol_cls, http_protocol_cls, unused_tcp_port: int
ws_protocol_cls: "typing.Type[WSProtocol | WebSocketProtocol]",
http_protocol_cls,
unused_tcp_port: int,
):
disconnected_message = {}

Expand Down Expand Up @@ -1053,10 +1054,11 @@ async def websocket_session(url):


@pytest.mark.anyio
@pytest.mark.parametrize("ws_protocol_cls", WS_PROTOCOLS)
@pytest.mark.parametrize("http_protocol_cls", HTTP_PROTOCOLS)
async def test_server_reject_connection_with_multibody_response(
ws_protocol_cls, http_protocol_cls, unused_tcp_port: int
ws_protocol_cls: "typing.Type[WSProtocol | WebSocketProtocol]",
http_protocol_cls,
unused_tcp_port: int,
):
disconnected_message = {}

Expand Down Expand Up @@ -1106,10 +1108,11 @@ async def websocket_session(url):


@pytest.mark.anyio
@pytest.mark.parametrize("ws_protocol_cls", WS_PROTOCOLS)
@pytest.mark.parametrize("http_protocol_cls", HTTP_PROTOCOLS)
async def test_server_reject_connection_with_invalid_status(
ws_protocol_cls, http_protocol_cls, unused_tcp_port: int
ws_protocol_cls: "typing.Type[WSProtocol | WebSocketProtocol]",
http_protocol_cls,
unused_tcp_port: int,
):
async def app(scope, receive, send):
assert scope["type"] == "websocket"
Expand Down Expand Up @@ -1148,10 +1151,11 @@ async def websocket_session(url):


@pytest.mark.anyio
@pytest.mark.parametrize("ws_protocol_cls", WS_PROTOCOLS)
@pytest.mark.parametrize("http_protocol_cls", HTTP_PROTOCOLS)
async def test_server_reject_connection_with_body_nolength(
ws_protocol_cls, http_protocol_cls, unused_tcp_port: int
ws_protocol_cls: "typing.Type[WSProtocol | WebSocketProtocol]",
http_protocol_cls,
unused_tcp_port: int,
):
# test that the server can send a response with a body but no content-length
async def app(scope, receive, send):
Expand Down Expand Up @@ -1197,10 +1201,11 @@ async def websocket_session(url):


@pytest.mark.anyio
@pytest.mark.parametrize("ws_protocol_cls", WS_PROTOCOLS)
@pytest.mark.parametrize("http_protocol_cls", HTTP_PROTOCOLS)
async def test_server_reject_connection_with_invalid_msg(
ws_protocol_cls, http_protocol_cls, unused_tcp_port: int
ws_protocol_cls: "typing.Type[WSProtocol | WebSocketProtocol]",
http_protocol_cls,
unused_tcp_port: int,
):
async def app(scope, receive, send):
assert scope["type"] == "websocket"
Expand Down Expand Up @@ -1237,10 +1242,11 @@ async def websocket_session(url):


@pytest.mark.anyio
@pytest.mark.parametrize("ws_protocol_cls", WS_PROTOCOLS)
@pytest.mark.parametrize("http_protocol_cls", HTTP_PROTOCOLS)
async def test_server_reject_connection_with_missing_body(
ws_protocol_cls, http_protocol_cls, unused_tcp_port: int
ws_protocol_cls: "typing.Type[WSProtocol | WebSocketProtocol]",
http_protocol_cls,
unused_tcp_port: int,
):
async def app(scope, receive, send):
assert scope["type"] == "websocket"
Expand Down

0 comments on commit 435e6dc

Please sign in to comment.