Skip to content

Commit 5c8341a

Browse files
committed
fix invalid params regression tests
1 parent 57351d6 commit 5c8341a

1 file changed

Lines changed: 19 additions & 22 deletions

File tree

tests/test_internal.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from galaxy.api.plugin import Plugin
44
from galaxy.api.consts import Platform
5-
from galaxy.api.jsonrpc import InvalidParams
5+
from galaxy.api.jsonrpc import Connection, InvalidParams, Request
66
from galaxy.unittest.mock import delayed_return_value_iterable
77

88
from tests import create_message, get_messages
@@ -101,33 +101,30 @@ async def test_tick_after_handshake(plugin, read):
101101

102102

103103
@pytest.mark.asyncio
104-
async def test_notification_invalid_params_does_not_crash(plugin, read, write):
105-
request = {
106-
"jsonrpc": "2.0",
107-
"method": "install_game",
108-
"params": {}
109-
}
110-
read.side_effect = [create_message(request), b""]
104+
async def test_notification_invalid_params_does_not_crash(plugin, read, write, reader, writer):
105+
called = False
111106

112-
await plugin.run()
113-
await plugin.wait_closed()
107+
def callback(game_id):
108+
nonlocal called
109+
called = True
110+
111+
connection = Connection(reader, writer)
112+
connection.register_notification("install_game", callback, immediate=True)
113+
connection._handle_notification(Request(method="install_game", params={}, id=None))
114114

115-
plugin.install_game.assert_not_called()
115+
assert called is False
116116
assert get_messages(write) == []
117117

118118

119119
@pytest.mark.asyncio
120-
async def test_request_invalid_params_returns_error(plugin, read, write):
121-
request = {
122-
"jsonrpc": "2.0",
123-
"id": "8",
124-
"method": "start_achievements_import",
125-
"params": {}
126-
}
127-
read.side_effect = [create_message(request), b""]
128-
129-
await plugin.run()
130-
await plugin.wait_closed()
120+
async def test_request_invalid_params_returns_error(plugin, read, write, reader, writer):
121+
async def callback(game_ids):
122+
return game_ids
123+
124+
connection = Connection(reader, writer)
125+
connection.register_method("start_achievements_import", callback, immediate=False)
126+
connection._handle_request(Request(method="start_achievements_import", params={}, id="8"))
127+
await connection.wait_closed()
131128

132129
assert get_messages(write) == [
133130
{

0 commit comments

Comments
 (0)