From cee2897b1e5ace4a697d40450d87d53d0ef3a853 Mon Sep 17 00:00:00 2001 From: zlg Date: Tue, 30 Apr 2019 20:34:15 -0700 Subject: Release version 0.3 beta 4 This release brings JSON import and export support. --- tests/test_vgstash_cli.py | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'tests/test_vgstash_cli.py') diff --git a/tests/test_vgstash_cli.py b/tests/test_vgstash_cli.py index c3b60d6..30eff62 100644 --- a/tests/test_vgstash_cli.py +++ b/tests/test_vgstash_cli.py @@ -241,6 +241,38 @@ def test_notes_edit(): assert list_result.exit_code == 0 +def test_import_file_json(): + runner = CliRunner() + result = runner.invoke(vgstash_cli.cli, ["import", "tests/data/test_import.json"]) + if verbose: + print(result.output) + assert result.exit_code == 0 + assert result.output == "Successfully imported 2 games from {}.\n".format(os.path.join(os.getcwd(), "tests/data/test_import.json")) + + # List the results to make sure they match what the editor has. + list_runner = CliRunner() + list_result = runner.invoke(vgstash_cli.cli, ['list', '-w', '40']) + if verbose: + print(list_result.output) + assert list_result.exit_code == 0 + + +def test_import_file_json_update(): + runner = CliRunner() + result = runner.invoke(vgstash_cli.cli, ["import", "tests/data/test_import.json", "-u"]) + if verbose: + print(result.output) + assert result.exit_code == 0 + assert result.output == "Successfully imported 3 games from {}.\n".format(os.path.join(os.getcwd(), "tests/data/test_import.json")) + + # List the results to make sure they match what the editor has. + list_runner = CliRunner() + list_result = runner.invoke(vgstash_cli.cli, ['list', '-w', '40']) + if verbose: + print(list_result.output) + assert list_result.exit_code == 0 + + def test_import_file_yaml(): runner = CliRunner() result = runner.invoke(vgstash_cli.cli, ["import", "tests/data/test_import.yml"]) @@ -273,10 +305,19 @@ def test_import_file_yaml_update(): assert list_result.exit_code == 0 +def test_export_file_json(): + runner = CliRunner() + result = runner.invoke(vgstash_cli.cli, ["export", "-f", "json", "tests/data/test_export.json"]) + if verbose: + print(result.output) + assert result.exit_code == 0 + assert result.output == "Successfully exported 8 games to {}.\n".format(os.path.join(os.getcwd(), "tests/data/test_export.json")) + + def test_export_file_yaml(): runner = CliRunner() result = runner.invoke(vgstash_cli.cli, ["export", "-f", "yaml", "tests/data/test_export.yml"]) if verbose: print(result.output) assert result.exit_code == 0 - assert result.output == "Successfully exported 6 games to {}.\n".format(os.path.join(os.getcwd(), "tests/data/test_export.yml")) + assert result.output == "Successfully exported 8 games to {}.\n".format(os.path.join(os.getcwd(), "tests/data/test_export.yml")) -- cgit v1.2.3-54-g00ecf