summaryrefslogtreecommitdiff
path: root/src/vgstash/test_vgstash_cli.py
diff options
context:
space:
mode:
authorzlg <zlg@zlg.space>2018-09-08 19:15:48 -0700
committerzlg <zlg@zlg.space>2018-09-08 19:15:48 -0700
commitb2d47d2ca978e2cd62be4cb6fe0471598427b8b7 (patch)
treee453e5da5f934058dc65bc0b352642305773bea7 /src/vgstash/test_vgstash_cli.py
parentAdd remaining filters to vgstash package (diff)
downloadvgstash-b2d47d2ca978e2cd62be4cb6fe0471598427b8b7.tar.gz
vgstash-b2d47d2ca978e2cd62be4cb6fe0471598427b8b7.tar.bz2
vgstash-b2d47d2ca978e2cd62be4cb6fe0471598427b8b7.tar.xz
vgstash-b2d47d2ca978e2cd62be4cb6fe0471598427b8b7.zip
cli: add '--raw' option to list command
Add '--raw' option to the list command, in addition to proper note expansion. Newline characters in notes are escaped to be friendly to scripting. This option may be shortened to '-r' at the user's convenience. In raw output mode, the information is formatted in plain pipe-delimited strings, one line per row: title|system|ownership|progress|notes ownership and progress are printed in their numeric form, consistent with the OWNERSHIP and PROGRESS dictionaries in the vgstash package. An empty notes field will result in a line ending with a pipe and no whitespace following it.
Diffstat (limited to 'src/vgstash/test_vgstash_cli.py')
-rw-r--r--src/vgstash/test_vgstash_cli.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/vgstash/test_vgstash_cli.py b/src/vgstash/test_vgstash_cli.py
index ac123ef..3ad661d 100644
--- a/src/vgstash/test_vgstash_cli.py
+++ b/src/vgstash/test_vgstash_cli.py
@@ -48,26 +48,36 @@ def test_add_full():
assert result.exit_code == 0
assert result.output == "Added Vectorman for Genesis. You do not own it and have beaten it. It also has notes.\n"
+def test_add_full_note_with_newline():
+ runner = CliRunner()
+ result = runner.invoke(vgstash_cli.cli, ['add', 'Vectorman 2', 'Genesis', 'p', 'p', 'beep\nboop'])
+ if verbose:
+ print(result.output)
+ assert result.exit_code == 0
+ assert result.output == "Added Vectorman 2 for Genesis. You physically own it and are playing it. It also has notes.\n"
+
def test_list():
runner = CliRunner()
- result = runner.invoke(vgstash_cli.list_games)
+ result = runner.invoke(vgstash_cli.list_games, ['--raw'])
if verbose:
print(result.output)
assert result.exit_code == 0
assert result.output == '\n'.join((
'Sonic the Hedgehog 2|Genesis|0|3|',
'Vectorman|Genesis|0|3|beep',
+ 'Vectorman 2|Genesis|1|2|beep\\nboop',
'Super Mario Bros.|NES|1|2|',
'The Legend of Zelda|NES|2|2|\n',
))
def test_list_filter():
runner = CliRunner()
- result = runner.invoke(vgstash_cli.cli, ['list', 'playlog'])
+ result = runner.invoke(vgstash_cli.cli, ['list', '-r', 'playlog'])
if verbose:
print(result.output)
assert result.exit_code == 0
assert result.output == '\n'.join((
+ 'Vectorman 2|Genesis|1|2|beep\\nboop',
'Super Mario Bros.|NES|1|2|',
'The Legend of Zelda|NES|2|2|\n',
))