Skip to content

Commit d8c4242

Browse files
neiljptimabbott
authored andcommitted
VirtualFS tests: Improve test coverage.
1 parent 37206db commit d8c4242

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

zulip_bots/zulip_bots/bots/virtual_fs/test_virtual_fs.py

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,46 @@
44
from __future__ import print_function
55

66
from zulip_bots.test_lib import BotTestCase
7+
from zulip_bots.lib import StateHandler
78

89
class TestVirtualFsBot(BotTestCase):
910
bot_name = "virtual_fs"
1011

1112
def test_bot(self):
13+
help_txt = ('[email protected]:\n\nThis bot implements a virtual file system for a stream.\n'
14+
'The locations of text are persisted for the lifetime of the bot\n'
15+
'running, and if you rename a stream, you will lose the info.\n'
16+
'Example commands:\n\n```\n'
17+
'@mention-bot sample_conversation: sample conversation with the bot\n'
18+
'@mention-bot mkdir: create a directory\n'
19+
'@mention-bot ls: list a directory\n'
20+
'@mention-bot cd: change directory\n'
21+
'@mention-bot pwd: show current path\n'
22+
'@mention-bot write: write text\n'
23+
'@mention-bot read: read text\n'
24+
'@mention-bot rm: remove a file\n'
25+
'@mention-bot rmdir: remove a directory\n'
26+
'```\n'
27+
'Use commands like `@mention-bot help write` for more details on specific\ncommands.\n')
1228
expected = {
1329
"cd /home": "[email protected]:\nERROR: invalid path",
1430
"mkdir home": "[email protected]:\ndirectory created",
1531
"pwd": "[email protected]:\n/",
16-
"help": ('[email protected]:\n\nThis bot implements a virtual file system for a stream.\n'
17-
'The locations of text are persisted for the lifetime of the bot\n'
18-
'running, and if you rename a stream, you will lose the info.\n'
19-
'Example commands:\n\n```\n'
20-
'@mention-bot sample_conversation: sample conversation with the bot\n'
21-
'@mention-bot mkdir: create a directory\n'
22-
'@mention-bot ls: list a directory\n'
23-
'@mention-bot cd: change directory\n'
24-
'@mention-bot pwd: show current path\n'
25-
'@mention-bot write: write text\n'
26-
'@mention-bot read: read text\n'
27-
'@mention-bot rm: remove a file\n'
28-
'@mention-bot rmdir: remove a directory\n'
29-
'```\n'
30-
'Use commands like `@mention-bot help write` for more details on specific\ncommands.\n'),
32+
"help": help_txt,
3133
"help ls": "[email protected]:\nsyntax: ls <optional_path>",
32-
"": ('[email protected]:\n\nThis bot implements a virtual file system for a stream.\n'
33-
'The locations of text are persisted for the lifetime of the bot\n'
34-
'running, and if you rename a stream, you will lose the info.\n'
35-
'Example commands:\n\n```\n'
36-
'@mention-bot sample_conversation: sample conversation with the bot\n'
37-
'@mention-bot mkdir: create a directory\n'
38-
'@mention-bot ls: list a directory\n'
39-
'@mention-bot cd: change directory\n'
40-
'@mention-bot pwd: show current path\n'
41-
'@mention-bot write: write text\n'
42-
'@mention-bot read: read text\n'
43-
'@mention-bot rm: remove a file\n'
44-
'@mention-bot rmdir: remove a directory\n'
45-
'```\n'
46-
'Use commands like `@mention-bot help write` for more details on specific\ncommands.\n'),
34+
"": help_txt,
4735
}
4836
self.check_expected_responses(expected)
37+
38+
expected = [
39+
("help", help_txt),
40+
("help ls", "[email protected]:\nsyntax: ls <optional_path>"),
41+
("", help_txt),
42+
("pwd", "[email protected]:\n/"),
43+
("cd /home", "[email protected]:\nERROR: invalid path"),
44+
("mkdir home", "[email protected]:\ndirectory created"),
45+
("cd /home", "[email protected]:\nCurrent path: /home/"),
46+
]
47+
48+
state_handler = StateHandler()
49+
self.check_expected_responses(expected, state_handler = state_handler)

0 commit comments

Comments
 (0)