From fb16d80daba2213e07f33410e41a774c565a95de Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sat, 20 Sep 2025 10:38:23 +0200 Subject: [PATCH] Add IrcConnAbort test, allow unlogged server test puts. --- ircplom/testing.py | 11 +++++++++-- test.txt | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/ircplom/testing.py b/ircplom/testing.py index befa3dc..f8b2004 100644 --- a/ircplom/testing.py +++ b/ircplom/testing.py @@ -5,7 +5,7 @@ from typing import Generator, Iterator, Optional from ircplom.events import Event, Loop, QueueMixin from ircplom.client import IrcConnection, IrcConnSetup from ircplom.client_tui import ClientKnowingTui, ClientTui -from ircplom.irc_conn import IrcMessage +from ircplom.irc_conn import IrcConnAbortException, IrcMessage from ircplom.tui_base import TerminalInterface, TuiEvent @@ -78,6 +78,10 @@ class _FakeIrcConnection(IrcConnection): except QueueEmpty: yield None continue + if msg == 'FAKE_IRC_CONN_ABORT_EXCEPTION': + err = IrcConnAbortException(msg) + yield self._on_handled_loop_exception(err) + return yield self._make_recv_event(IrcMessage.from_raw(msg)) @@ -143,7 +147,10 @@ class TestingClientTui(ClientTui): self._q_keypresses.put('KEY_ENTER') continue if ':' in context and msg.startswith('< '): - client = self._clients[int(context.split(':')[0])] + client_id, win_ids = context.split(':') + client = self._clients[int(client_id)] assert isinstance(client.conn, _FakeIrcConnection) client.conn.put_server_msg(msg[2:]) + if not win_ids: + continue break diff --git a/test.txt b/test.txt index 3f4f9c0..f515370 100644 --- a/test.txt +++ b/test.txt @@ -399,6 +399,33 @@ 8,9 $ isupport:USERLEN set to: [10] 8,9 !$ nickname refused for bad format, giving up +# test failing third connection +> /connect baz.baz.baz baz baz:baz +10,11 $ isupport cleared +10,11 $ isupport:CHANTYPES set to: [#&] +10,11 $ isupport:PREFIX set to: [(ov)@+] +10,11 $ isupport:USERLEN set to: [10] +10,11 $ hostname set to: [baz.baz.baz] +10,11 $ port set to: [-1] +10,11 $ nick_wanted set to: [baz] +10,11 $ user_wanted set to: [baz] +10,11 $ realname set to: [baz] +10,11 $ port set to: [6697] +10,11 $ connection_state set to: [connecting] +10,11 $ connection_state set to: [connected] +, $ CONNECTED +2:11 > CAP LS :302 +2:11 > USER baz 0 * :baz +2:11 > NICK :baz +2: < FAKE_IRC_CONN_ABORT_EXCEPTION +10,11 !$ connection broken: FAKE_IRC_CONN_ABORT_EXCEPTION +10,11 $ connection_state set to: [] +, $ DISCONNECTED +10,11 $ isupport cleared +10,11 $ isupport:CHANTYPES set to: [#&] +10,11 $ isupport:PREFIX set to: [(ov)@+] +10,11 $ isupport:USERLEN set to: [10] + # check that (save TUI tests assuming start on window 0, and no 4 yet) on reconnect, all the same effects can be expected > /reconnect repeat 63:65 -- 2.30.2