|
4 | 4 | from __future__ import print_function
|
5 | 5 |
|
6 | 6 | from zulip_bots.test_lib import BotTestCase
|
| 7 | +from zulip_bots.lib import StateHandler |
7 | 8 |
|
8 | 9 | class TestVirtualFsBot(BotTestCase):
|
9 | 10 | bot_name = "virtual_fs"
|
10 | 11 |
|
11 | 12 | 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') |
12 | 28 | expected = {
|
13 | 29 | "cd /home": "[email protected]:\nERROR: invalid path",
|
14 | 30 | "mkdir home": "[email protected]:\ndirectory created",
|
15 | 31 |
|
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, |
31 | 33 | "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, |
47 | 35 | }
|
48 | 36 | 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 | + |
| 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