import struct import zipfile import pytest from handler.cloud_sync_psp import ( _BUNDLE_MAX_MEMBERS, PspFilePath, _bundle_folder, _load_bundle_entries, _write_bundle, is_psp_bundle_file_name, parse_sfo, resolve_psp_path, ) def _build_fake_sfo(fields: dict[str, str | int]) -> bytes: """Builds a minimal valid PARAM.SFO buffer for the given fields, to round-trip against `parse_sfo` without needing a real PPSSPP capture.""" key_table = bytearray() data_table = bytearray() entries = [] for key, value in fields.items(): key_offset = len(key_table) key_table += key.encode("ascii") + b"\x00" data_offset = len(data_table) if isinstance(value, int): data_fmt = 0x0404 data_bytes = struct.pack("