diff options
Diffstat (limited to '')
-rw-r--r-- | tests/data/test_import.yml | 8 | ||||
-rw-r--r-- | tests/test_vgstash_cli.py | 43 |
2 files changed, 46 insertions, 5 deletions
diff --git a/tests/data/test_import.yml b/tests/data/test_import.yml index eb93579..b01538f 100644 --- a/tests/data/test_import.yml +++ b/tests/data/test_import.yml @@ -1,13 +1,13 @@ # vgstash DB file version 0.2 - ownership: 1 progress: 3 - system: NES - title: Super Mario Bros. + system: GBA + title: Fire Emblem notes: '' - ownership: 2 progress: 4 - system: 3DS - title: The Legend of Zelda + system: Switch + title: Puyo Puyo Tetris notes: '' - ownership: 2 progress: 3 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")) |