Skip to content

Commit

Permalink
[Test] Fix all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aicorein committed Feb 23, 2025
1 parent 0ffb845 commit 17c499a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
9 changes: 2 additions & 7 deletions tests/onebot/v11/test_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from asyncio import Queue, create_task

from melobot.bot import Bot
from melobot.handle import GetParseArgs, on_start_match
from melobot.handle import on_start_match
from melobot.log import GenericLogger
from melobot.plugin import PluginPlanner
from melobot.protocols.onebot.v11.adapter.base import Adapter
Expand Down Expand Up @@ -55,12 +55,7 @@


@h
async def _flow(
bot: Bot,
event: MessageEvent,
logger: GenericLogger,
args: CmdArgs = GetParseArgs(),
) -> None:
async def _flow(bot: Bot, logger: GenericLogger, args: CmdArgs) -> None:
logger.info(args)
await bot.close()
_SUCCESS_SIGNAL.set()
Expand Down
6 changes: 2 additions & 4 deletions tests/onebot/v11/test_io_duplex_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ async def put_input(s: str):
@singleton
class MockClientSession:
async def post(self, url, *args, **kwargs):
await _OUT_BUF.put(
json.dumps({"action": url.split("/")[-1], "params": kwargs["json"]})
)
await _OUT_BUF.put(json.dumps({"action": url.split("/")[-1], "params": kwargs["json"]}))
resp = aiohttp.web.Response(status=200)
resp.json = to_async(lambda: _TEST_ECHO_DICT | {"echo": _TEST_ACTION.id})
return resp
Expand All @@ -73,7 +71,7 @@ async def test_http(monkeypatch) -> None:
with LoggerCtx().unfold(Logger()):
aiohttp._ClientSession = aiohttp.ClientSession
monkeypatch.setattr(aiohttp, "ClientSession", lambda: MockClientSession())
io = HttpIO("localhost", 8080, "localhost", 9090)
io = HttpIO("http://localhost:80", "localhost", 9090)
create_task(put_input(json.dumps(_TEST_EVENT_DICT)))

async with io:
Expand Down

0 comments on commit 17c499a

Please sign in to comment.