Skip to content

Commit

Permalink
test: extend test bidi channel test
Browse files Browse the repository at this point in the history
  • Loading branch information
sadym-chromium committed May 30, 2024
1 parent 74241ab commit 1192171
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions tests/session/test_protocol_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# limitations under the License.

import pytest
from test_helpers import (execute_command, json, read_JSON_message,
send_JSON_command)
from test_helpers import (AnyExtending, execute_command, json,
read_JSON_message, send_JSON_command)

# Tests for "handle an incoming message" error handling, when the message
# can't be decoded as known command.
Expand Down Expand Up @@ -89,24 +89,42 @@ async def test_session_status(websocket):


@pytest.mark.asyncio
async def test_channel_non_empty(websocket):
await send_JSON_command(
async def test_channel_non_empty_non_static_command(websocket):
command_id = await send_JSON_command(websocket, {
"method": "session.status",
"params": {},
"channel": "SOME_CHANNEL"
})
resp = await read_JSON_message(websocket)
assert resp == AnyExtending({
"id": command_id,
"channel": "SOME_CHANNEL",
"type": "success",
"result": {
"ready": False,
"message": "already connected"
}
})


@pytest.mark.asyncio
async def test_channel_non_empty_static_command(websocket):
command_id = await send_JSON_command(
websocket, {
"id": 6000,
"method": "session.status",
"id": 2,
"method": "browsingContext.getTree",
"params": {},
"channel": "SOME_CHANNEL"
})
resp = await read_JSON_message(websocket)
assert resp == {
"id": 6000,
assert resp == AnyExtending({
"id": command_id,
"channel": "SOME_CHANNEL",
"type": "success",
"result": {
"ready": False,
"message": "already connected"
"contexts": [{}]
}
}
})


@pytest.mark.asyncio
Expand All @@ -118,14 +136,14 @@ async def test_channel_empty(websocket):
"channel": ""
})
resp = await read_JSON_message(websocket)
assert resp == {
assert resp == AnyExtending({
"id": 7000,
"type": "success",
"result": {
"ready": False,
"message": "already connected"
}
}
})


@pytest.mark.asyncio
Expand Down

0 comments on commit 1192171

Please sign in to comment.