From 88ca5c5152e787c9c004e64826b1720a7a113268 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Wed, 21 Jun 2023 17:54:27 -0500 Subject: [PATCH] more tests for command invocations --- gp2040ce_bintools/storage.py | 1 + tests/test_commands.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/gp2040ce_bintools/storage.py b/gp2040ce_bintools/storage.py index 5a2c080..a0ae3c5 100644 --- a/gp2040ce_bintools/storage.py +++ b/gp2040ce_bintools/storage.py @@ -72,6 +72,7 @@ def get_config_from_file(filename: str, whole_board: bool = False) -> dict: Args: filename: the filename of the file to open and read + whole_board: optional, if true, attempt to find the storage section from its normal location on a board Returns: the parsed configuration """ diff --git a/tests/test_commands.py b/tests/test_commands.py index 4925ff9..04bc72c 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -15,3 +15,19 @@ def test_help_flag(): result = run(['visualize-storage', '-h'], capture_output=True, encoding='utf8') assert 'usage: visualize-storage' in result.stdout assert 'Read the configuration section from a dump of a GP2040-CE board' in result.stdout + + +def test_storage_dump_invocation(): + """Test that a normal invocation against a dump works.""" + result = run(['visualize-storage', '-P', 'tests/test-files/proto-files', 'tests/test-files/test-storage-area.bin'], + capture_output=True, encoding='utf8') + assert 'boardVersion: "v0.7.2"' in result.stdout + + +def test_debug_storage_dump_invocation(): + """Test that a normal invocation against a dump works.""" + result = run(['visualize-storage', '-d', '-P', 'tests/test-files/proto-files', + 'tests/test-files/test-storage-area.bin'], + capture_output=True, encoding='utf8') + assert 'boardVersion: "v0.7.2"' in result.stdout + assert 'length of content to look for footer in: 8192' in result.stderr