| import sys, os; sys.path.insert(0, "src") |
| os.environ["BUDDY_FORCE_FAKE_RUNTIME"] = "1" |
| from buddy_fusion.runtime import default_runtime, LlamaCppBuddyRuntime |
| from buddy_fusion.fallback import fallback_genome |
| from buddy_fusion.genome import genome_to_dict, genome_from_dict, ARCHETYPES |
|
|
|
|
| def test_fake_fuse_returns_valid_genome_dict(): |
| rt = default_runtime() |
| a, b = genome_to_dict(fallback_genome(1)), genome_to_dict(fallback_genome(2)) |
| child, status = rt.fuse_genomes(a, b) |
| g = genome_from_dict(child) |
| assert g.archetype in ARCHETYPES |
| assert status.used_fallback is True |
|
|
|
|
| def test_fake_interpret_command_adds_part(): |
| rt = default_runtime() |
| g = genome_to_dict(fallback_genome(1, "chick")) |
| out, status = rt.interpret_genome_command(g, "add two horns") |
| assert any(p.kind == "horn" for p in genome_from_dict(out).parts) |
|
|
|
|
| def test_fake_interpret_command_changes_archetype(): |
| rt = default_runtime() |
| g = genome_to_dict(fallback_genome(1, "chick")) |
| out, _ = rt.interpret_genome_command(g, "turn it into a frog") |
| assert genome_from_dict(out).archetype == "frog" |
|
|
|
|
| def test_fake_interpret_command_unknown_is_noop(): |
| rt = default_runtime() |
| g = genome_to_dict(fallback_genome(1, "chick")) |
| out, _ = rt.interpret_genome_command(g, "hello there") |
| assert genome_from_dict(out).archetype == "chick" |
|
|
|
|
| def test_real_runtime_empty_edit_falls_back_to_keyword_editor(): |
| |
| |
| |
| |
| rt = LlamaCppBuddyRuntime() |
| rt._chat_json = lambda *a, **k: {} |
| g = genome_to_dict(fallback_genome(1, "chick")) |
| out, status = rt.interpret_genome_command(g, "add two horns") |
| assert any(p.kind == "horn" for p in genome_from_dict(out).parts) |
| assert status.used_fallback is True |
|
|
|
|
| def test_real_runtime_uses_model_edit_when_it_changes_the_look(): |
| rt = LlamaCppBuddyRuntime() |
| rt._chat_json = lambda *a, **k: {"archetype": "frog"} |
| g = genome_to_dict(fallback_genome(1, "chick")) |
| out, status = rt.interpret_genome_command(g, "make it a frog") |
| assert genome_from_dict(out).archetype == "frog" |
| assert status.used_fallback is False |
|
|