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):
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()
--- /dev/null
+> /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 <