#!/usr/bin/env python3 # Author: cirakg & claude ai # Summary: Generate the settings-spike test strings: one .txt per string and an index.html with copy buttons. """Generate the test strings for the M1 settings spike (docs/SETTINGS_SPIKE.md). Length strings look like N=1000|abcdef...P0050...P0100...xyzEND "N=|" says how long the string should be, a marker "P" sits at every 50th character, and "END" closes it. If the phone app cuts a string, the watch shows a wrong length and no "END"; the last marker it shows tells roughly where the cut happened. Only letters, digits, "=", "|" are used, so the length tests don't also test character handling. special.txt holds the characters that may be rejected (& < > \\ " { } %), non-ASCII text, a fake otpauth URI and a JSON fragment. Usage: python3 make_test_strings.py (writes into its own folder) """ from __future__ import annotations import html from pathlib import Path LENGTHS = (100, 255, 256, 500, 800, 801, 1000, 2000, 4000, 8000) SPECIAL = ( 'special: & < > \\ " { } % | non-ASCII: äöü ß € 😀 | ' "otpauth://totp/Fake:alice?secret=JBSWY3DPEHPK3PXP&issuer=Fake&digits=6 | " '{"name":"Fake","path":"a\\/b"} END' ) HEADER = ( "# Author: cirakg & claude ai\n# Summary: {summary}\n" "# Copy ONLY the last line (the test string) into a settings field.\n\n" ) LETTERS = "abcdefghijklmnopqrstuvwxyz" def marker_string(length: int) -> str: """A string of exactly `length` characters with position markers.""" text = f"N={length}|" i = 0 while len(text) < length - 3: pos = len(text) if pos % 50 == 0 and pos + 5 <= length - 3: text += f"P{pos:04d}" else: text += LETTERS[i % len(LETTERS)] i += 1 text += "END" assert len(text) == length, (length, len(text)) return text def main() -> None: here = Path(__file__).resolve().parent entries = [(f"len-{n:04d}", f"{n} characters", marker_string(n)) for n in LENGTHS] entries.append(("special", "special characters", SPECIAL)) for name, label, value in entries: (here / f"{name}.txt").write_text(HEADER.format(summary=f"Settings spike test string: {label}.") + value + "\n") cards = "\n".join( f"

{html.escape(label)}

" f'' f"
" for name, label, value in entries ) page = f""" Settings spike test strings

Settings spike test strings

Tap Copy, then paste into one of the Text fields in the app settings. Expected lengths are in each heading.

{cards} """ (here / "index.html").write_text(page) print(f"wrote {len(entries)} test strings and index.html into {here}") if __name__ == "__main__": main()