hatchimera / tests /test_freeform_edit.py
arkai2025's picture
test+docs: repair edit_creature 4-tuple test; wiki for canvas + one-call tweak
2ae67df
Raw
History Blame Contribute Delete
1.43 kB
from buddy_fusion.fallback import edit_boxes_fallback
BASE = [{"x": 0, "y": 0, "z": 0, "w": 4, "h": 4, "d": 4, "color": "#4caf50"}]
def test_recolor_changes_dominant_colour():
out = edit_boxes_fallback(BASE, "make it purple")
assert any(b["color"] == "#a855f7" for b in out)
assert all(b["color"] != "#4caf50" for b in out) # body got recolored
def test_add_horn_appends_boxes():
out = edit_boxes_fallback(BASE, "add two horns")
assert len(out) > len(BASE)
def test_add_wings_appends_boxes():
out = edit_boxes_fallback(BASE, "give it wings")
assert len(out) > len(BASE)
def test_unknown_instruction_returns_unchanged_content():
out = edit_boxes_fallback(BASE, "zxqw nonsense")
assert out == BASE
def test_does_not_mutate_input():
snapshot = [dict(b) for b in BASE]
edit_boxes_fallback(BASE, "make it purple")
assert BASE == snapshot
def test_empty_input_returns_empty():
assert edit_boxes_fallback([], "add a horn") == []
def test_fake_runtime_edit_creature():
from buddy_fusion.runtime import FakeBuddyRuntime
rt = FakeBuddyRuntime()
genome = {"name": "X", "archetype": "chick", "parts": []}
g, boxes, tweaks, status = rt.edit_creature(genome, BASE, "add two horns")
assert len(boxes) > len(BASE)
assert status.used_fallback
assert g["name"] == "X"
assert len(tweaks) == 4 and all(isinstance(t, str) and t for t in tweaks)