The Windows app builds the flash save when it runs, so the script reads that build and reports the method instead of guessing a packet. Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""The MidiSuite save report stays quiet when the packet is not in the file."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import importlib.util
|
|
import io
|
|
import sys
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
spec = importlib.util.spec_from_file_location(
|
|
"find_midisuite_save", ROOT / "scripts" / "find_midisuite_save.py"
|
|
)
|
|
finder = importlib.util.module_from_spec(spec)
|
|
assert spec.loader is not None
|
|
sys.modules["find_midisuite_save"] = finder
|
|
spec.loader.exec_module(finder)
|
|
|
|
|
|
def test_report_names_the_save_method_when_no_packet_is_stored() -> None:
|
|
blob = b"\x00flashSave0\x00save0Packet\x00smc_pad_desktop_save\x00"
|
|
text = finder.report(blob)
|
|
assert "flashSave0" in text
|
|
assert "save0Packet" in text
|
|
assert "Stored 00 59 read/write packets:\n none" in text
|
|
assert "Nothing was sent to the pad." in text
|
|
|
|
|
|
def test_report_lists_a_stored_write_packet() -> None:
|
|
blob = b"\x00\x59\x22\x01\x00\x00"
|
|
text = finder.report(blob)
|
|
assert "command 0x22 write" in text
|
|
|
|
|
|
def test_app_so_reads_the_snapshot_out_of_the_zip() -> None:
|
|
raw = io.BytesIO()
|
|
with zipfile.ZipFile(raw, "w") as archive:
|
|
archive.writestr(finder.APP_SO, b"flashSave0")
|
|
assert finder.app_so(raw.getvalue()) == b"flashSave0"
|