From 169b49d1cd95b4e80bc45268b2265e730bf7be18 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Mon, 15 Sep 2025 09:22:02 +0200 Subject: [PATCH] Move test instructions/expectations into separate non-code file. --- ircplom/testing.py | 59 ++++------------------------------------------ test.txt | 49 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 55 deletions(-) create mode 100644 test.txt diff --git a/ircplom/testing.py b/ircplom/testing.py index 4eeb6d5..8bfb173 100644 --- a/ircplom/testing.py +++ b/ircplom/testing.py @@ -9,59 +9,7 @@ from ircplom.irc_conn import IrcMessage from ircplom.tui_base import TerminalInterface, TuiEvent -_PLAYBOOK: tuple[str, ...] = ( - '> /help', - '0 # commands available in this window:', - '0 # /connect HOST_PORT [NICKNAME_PW] [REALNAME]', - '0 # /help', - '0 # /list', - '0 # /prompt_enter', - '0 # /quit', - '0 # /window TOWARDS', - '0 # /window.history.scroll DIRECTION', - '0 # /window.paste', - '0 # /window.prompt.backspace', - '0 # /window.prompt.move_cursor DIRECTION', - '0 # /window.prompt.scroll DIRECTION', - '> /list', - '0 # windows available via /window:', - '0 # 0) :start', - '> /connect foo.bar.baz foo:bar baz', - '1,2 $ caps cleared', - '1,2 $ caps cleared', - '1,2 $ hostname set to: [foo.bar.baz]', - '1,2 $ port set to: [-1]', - '1,2 $ nick_wanted set to: [foo]', - '1,2 $ realname set to: [baz]', - '1,2 $ password set to: [bar]', - '1,2 $ port set to: [6697]', - '1,2 $ connection_state set to: [connecting]', - '1,2 $ channels cleared', - '1,2 $ users cleared', - '1,2 $ ?!?@? renames ?', - '1,2 $ users:me:user set to: [plom]', - '1,2 $ connection_state set to: [connected]', - '1,2 $ caps cleared', - '2 > CAP LS :302', - '2 > USER plom 0 * :baz', - '2 > NICK :foo', - '2 < :*.?.net NOTICE * :*** Looking up your ident...', - '1,2 $$$ *** Looking up your ident...', - '2 < :*.?.net NOTICE * :*** Looking up your hostname...', - '1,2 $$$ *** Looking up your hostname...', - '2 < :*.?.net NOTICE * :*** Found your hostname (…) -- cached...', - '1,2 $$$ *** Found your hostname (…) -- cached...', - '2 < :*.?.net CAP * LS : foo bar sasl=PLAIN,EXTERNAL baz', - '1,2 $ isupport cleared', - '2 > CAP REQ :sasl', - '2 > CAP :LIST', - '2 < PING :?', - '2 > PONG :?', - '> /quit', - '2 < :*.?.net CAP ? ACK :sasl', - '2 < :*.?.net CAP ? LIST :cap-notify sasl', - '0 < ', -) +_PATH_TEST_TXT = './test.txt' class TestTerminal(QueueMixin, TerminalInterface): @@ -136,14 +84,15 @@ class _TestClientKnowingTui(ClientKnowingTui): class TestingClientTui(ClientTui): - 'Collects keypresses via TestTerminal from PLAYBOOK, compares log results.' + 'Collects keypresses via TestTerminal and test file, compares log results.' _client: _TestClientKnowingTui def __init__(self, **kwargs) -> None: super().__init__(**kwargs) assert isinstance(self._term, TestTerminal) self._q_keypresses = self._term._q_keypresses - self._playbook = _PLAYBOOK + with open(_PATH_TEST_TXT, 'r', encoding='utf8') as f: + self._playbook = tuple(line[:-1] for line in f.readlines()) self._playbook_idx = -1 self._play_till_next_log() diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..fd27386 --- /dev/null +++ b/test.txt @@ -0,0 +1,49 @@ +> /help +0 # commands available in this window: +0 # /connect HOST_PORT [NICKNAME_PW] [REALNAME] +0 # /help +0 # /list +0 # /prompt_enter +0 # /quit +0 # /window TOWARDS +0 # /window.history.scroll DIRECTION +0 # /window.paste +0 # /window.prompt.backspace +0 # /window.prompt.move_cursor DIRECTION +0 # /window.prompt.scroll DIRECTION +> /list +0 # windows available via /window: +0 # 0) :start +> /connect foo.bar.baz foo:bar baz +1,2 $ caps cleared +1,2 $ caps cleared +1,2 $ hostname set to: [foo.bar.baz] +1,2 $ port set to: [-1] +1,2 $ nick_wanted set to: [foo] +1,2 $ realname set to: [baz] +1,2 $ password set to: [bar] +1,2 $ port set to: [6697] +1,2 $ connection_state set to: [connecting] +1,2 $ channels cleared +1,2 $ users cleared +1,2 $ ?!?@? renames ? +1,2 $ users:me:user set to: [plom] +1,2 $ connection_state set to: [connected] +1,2 $ caps cleared +2 > CAP LS :302 +2 > USER plom 0 * :baz +2 > NICK :foo +2 < :*.?.net NOTICE * :*** Looking up your ident... +1,2 $$$ *** Looking up your ident... +2 < :*.?.net NOTICE * :*** Looking up your hostname... +1,2 $$$ *** Looking up your hostname... +2 < :*.?.net NOTICE * :*** Found your hostname (…) -- cached... +1,2 $$$ *** Found your hostname (…) -- cached... +2 < :*.?.net CAP * LS : foo bar sasl=PLAIN,EXTERNAL baz +1,2 $ isupport cleared +2 > CAP REQ :sasl +2 > CAP :LIST +2 < PING :? +2 > PONG :? +> /quit +0 < -- 2.30.2