virtual_fs: Make sample_conversation() a list of tuples.
It's nice to see the requests and replies as separate strings when you're reading the code.
This commit is contained in:
parent
f8d51fc9d1
commit
5be72288db
|
@ -61,53 +61,53 @@ Use commands like `@mention-bot help write` for more details on specific
|
|||
commands.
|
||||
'''
|
||||
|
||||
def sample_conversation() -> List[str]:
|
||||
def sample_conversation() -> List[Tuple[str, str]]:
|
||||
return [
|
||||
('cd /\nCurrent path: /\n\n'),
|
||||
('cd /home\nERROR: invalid path\n\n'),
|
||||
('cd .\nERROR: invalid path\n\n'),
|
||||
('mkdir home\ndirectory created\n\n'),
|
||||
('cd home\nCurrent path: /home/\n\n'),
|
||||
('cd /home/\nCurrent path: /home/\n\n'),
|
||||
('mkdir stuff/\nERROR: stuff/ is not a valid name\n\n'),
|
||||
('mkdir stuff\ndirectory created\n\n'),
|
||||
('write stuff/file1 something\nfile written\n\n'),
|
||||
('read stuff/file1\nsomething\n\n'),
|
||||
('read /home/stuff/file1\nsomething\n\n'),
|
||||
('read home/stuff/file1\nERROR: file does not exist\n\n'),
|
||||
('pwd \n/home/\n\n'),
|
||||
('pwd bla\nERROR: syntax: pwd\n\n'),
|
||||
('ls bla foo\nERROR: syntax: ls <optional_path>\n\n'),
|
||||
('cd /\nCurrent path: /\n\n'),
|
||||
('rm home\nERROR: /home/ is a directory, file required\n\n'),
|
||||
('rmdir home\nremoved\n\n'),
|
||||
('ls \nWARNING: directory is empty\n\n'),
|
||||
('cd home\nERROR: invalid path\n\n'),
|
||||
('read /home/stuff/file1\nERROR: file does not exist\n\n'),
|
||||
('cd /\nCurrent path: /\n\n'),
|
||||
('write /foo contents of /foo\nfile written\n\n'),
|
||||
('read /foo\ncontents of /foo\n\n'),
|
||||
('write /bar Contents: bar bar\nfile written\n\n'),
|
||||
('read /bar\nContents: bar bar\n\n'),
|
||||
('write /bar invalid\nERROR: file already exists\n\n'),
|
||||
('rm /bar\nremoved\n\n'),
|
||||
('rm /bar\nERROR: file does not exist\n\n'),
|
||||
('write /bar new bar\nfile written\n\n'),
|
||||
('read /bar\nnew bar\n\n'),
|
||||
('write /yo/invalid whatever\nERROR: /yo is not a directory\n\n'),
|
||||
('mkdir /yo\ndirectory created\n\n'),
|
||||
('read /yo\nERROR: /yo/ is a directory, file required\n\n'),
|
||||
('ls /yo\nWARNING: directory is empty\n\n'),
|
||||
('read /yo/nada\nERROR: file does not exist\n\n'),
|
||||
('write /yo whatever\nERROR: file already exists\n\n'),
|
||||
('write /yo/apple red\nfile written\n\n'),
|
||||
('read /yo/apple\nred\n\n'),
|
||||
('mkdir /yo/apple\nERROR: file already exists\n\n'),
|
||||
('ls /invalid\nERROR: file does not exist\n\n'),
|
||||
('ls /foo\nERROR: /foo is not a directory\n\n'),
|
||||
('ls /\n* /*bar*\n* /*foo*\n* /yo/\n\n'),
|
||||
('invalid command\nERROR: unrecognized command\n\n'),
|
||||
('write\nERROR: syntax: write <path> <some_text>\n\n'),
|
||||
('cd /', 'Current path: /'),
|
||||
('cd /home', 'ERROR: invalid path'),
|
||||
('cd .', 'ERROR: invalid path'),
|
||||
('mkdir home', 'directory created'),
|
||||
('cd home', 'Current path: /home/'),
|
||||
('cd /home/', 'Current path: /home/'),
|
||||
('mkdir stuff/', 'ERROR: stuff/ is not a valid name'),
|
||||
('mkdir stuff', 'directory created'),
|
||||
('write stuff/file1 something', 'file written'),
|
||||
('read stuff/file1', 'something'),
|
||||
('read /home/stuff/file1', 'something'),
|
||||
('read home/stuff/file1', 'ERROR: file does not exist'),
|
||||
('pwd ', '/home/'),
|
||||
('pwd bla', 'ERROR: syntax: pwd'),
|
||||
('ls bla foo', 'ERROR: syntax: ls <optional_path>'),
|
||||
('cd /', 'Current path: /'),
|
||||
('rm home', 'ERROR: /home/ is a directory, file required'),
|
||||
('rmdir home', 'removed'),
|
||||
('ls ', 'WARNING: directory is empty'),
|
||||
('cd home', 'ERROR: invalid path'),
|
||||
('read /home/stuff/file1', 'ERROR: file does not exist'),
|
||||
('cd /', 'Current path: /'),
|
||||
('write /foo contents of /foo', 'file written'),
|
||||
('read /foo', 'contents of /foo'),
|
||||
('write /bar Contents: bar bar', 'file written'),
|
||||
('read /bar', 'Contents: bar bar'),
|
||||
('write /bar invalid', 'ERROR: file already exists'),
|
||||
('rm /bar', 'removed'),
|
||||
('rm /bar', 'ERROR: file does not exist'),
|
||||
('write /bar new bar', 'file written'),
|
||||
('read /bar', 'new bar'),
|
||||
('write /yo/invalid whatever', 'ERROR: /yo is not a directory'),
|
||||
('mkdir /yo', 'directory created'),
|
||||
('read /yo', 'ERROR: /yo/ is a directory, file required'),
|
||||
('ls /yo', 'WARNING: directory is empty'),
|
||||
('read /yo/nada', 'ERROR: file does not exist'),
|
||||
('write /yo whatever', 'ERROR: file already exists'),
|
||||
('write /yo/apple red', 'file written'),
|
||||
('read /yo/apple', 'red'),
|
||||
('mkdir /yo/apple', 'ERROR: file already exists'),
|
||||
('ls /invalid', 'ERROR: file does not exist'),
|
||||
('ls /foo', 'ERROR: /foo is not a directory'),
|
||||
('ls /', '* /*bar*\n* /*foo*\n* /yo/'),
|
||||
('invalid command', 'ERROR: unrecognized command'),
|
||||
('write', 'ERROR: syntax: write <path> <some_text>'),
|
||||
]
|
||||
|
||||
REGEXES = dict(
|
||||
|
@ -135,7 +135,12 @@ def fs_command(fs: str, user: str, cmd: str) -> Tuple[str, Any]:
|
|||
if cmd == 'help':
|
||||
return fs, get_help()
|
||||
if cmd == 'sample_conversation':
|
||||
return fs, (''.join(sample_conversation()))
|
||||
sample = '\n\n'.join(
|
||||
'\n'.join(tup)
|
||||
for tup
|
||||
in sample_conversation()
|
||||
)
|
||||
return fs, sample
|
||||
cmd_name = cmd.split()[0]
|
||||
cmd_args = cmd[len(cmd_name):].strip()
|
||||
commands = get_commands()
|
||||
|
|
Loading…
Reference in a new issue