home · contact · privacy
Move test instructions/expectations into separate non-code file.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 15 Sep 2025 07:22:02 +0000 (09:22 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 15 Sep 2025 07:22:02 +0000 (09:22 +0200)
ircplom/testing.py
test.txt [new file with mode: 0644]

index 4eeb6d54fa0b88cfe7a97b795be5d3995237ee11..8bfb17319c6d2c60369f5bf26d79e64f88c20578 100644 (file)
@@ -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 (file)
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 <