forked from rosebudai/OpenRCT2-Web
- describe_grid.py: Uses Gemini CLI to analyze each grid image and describe individual sprite cells, producing JSON descriptions that feed into the FAL.ai prompt for much better restyling fidelity - verify_sprites.py: Builds HTML comparison page (original vs restyled at 1x and 4x zoom), screenshots via Playwright, optionally judges with Gemini CLI - reskin.py: Add "describe" step between batch and generate; auto- resolve descriptions_dir for both describe and generate steps - Tests for describe_grid (6 tests covering parsing edge cases) - Fix 4x zoom CSS overflow in verification page Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""Tests for describe_grid.py."""
|
|
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
from describe_grid import parse_descriptions
|
|
|
|
|
|
def test_parse_descriptions_standard():
|
|
output = "A1: A wooden park bench with armrests\nA2: A metal lamp post with round light"
|
|
result = parse_descriptions(output, ["A1", "A2"])
|
|
assert result["A1"] == "A wooden park bench with armrests"
|
|
assert result["A2"] == "A metal lamp post with round light"
|
|
|
|
|
|
def test_parse_descriptions_markdown():
|
|
output = "**A1:** A wooden park bench\n**A2:** A lamp post"
|
|
result = parse_descriptions(output, ["A1", "A2"])
|
|
assert "bench" in result["A1"]
|
|
assert "lamp" in result["A2"]
|
|
|
|
|
|
def test_parse_descriptions_with_bullets():
|
|
output = "- A1: A wooden bench\n- A2: A lamp post"
|
|
result = parse_descriptions(output, ["A1", "A2"])
|
|
assert "bench" in result["A1"]
|
|
assert "lamp" in result["A2"]
|
|
|
|
|
|
def test_parse_descriptions_missing_label():
|
|
output = "A1: A bench"
|
|
result = parse_descriptions(output, ["A1", "A2"])
|
|
assert "A1" in result
|
|
assert "A2" not in result
|
|
|
|
|
|
def test_parse_descriptions_empty():
|
|
result = parse_descriptions("", ["A1"])
|
|
assert result == {}
|
|
|
|
|
|
def test_parse_descriptions_none():
|
|
result = parse_descriptions(None, ["A1"])
|
|
assert result == {}
|