diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-07-11 19:35:37 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-07-11 19:35:37 +0900 |
| commit | c2e5098d030fe902eff258e10d2fefc01226e4bf (patch) | |
| tree | 70885d7bae28fde887580d7b631cfa987ea12f19 /tests/test_templates.py | |
| parent | 93ca8050531ea99fa1d10ffb7d3f2c965e3a4ebe (diff) | |
テスト追加と修正
Diffstat (limited to 'tests/test_templates.py')
| -rw-r--r-- | tests/test_templates.py | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/test_templates.py b/tests/test_templates.py new file mode 100644 index 0000000..c6837b0 --- /dev/null +++ b/tests/test_templates.py @@ -0,0 +1,83 @@ +"""Tests for MML template generation.""" + +import pytest + +from mml_composemusic_mcp.server import compose_mml +from mml_composemusic_mcp.templates import DESCRIPTIONS, TEMPLATES, get_template + + +def test_all_templates_exist(): + for mode in ("ppmck", "pyxel"): + for name in ("basic", "melody", "chord", "drum", "empty"): + assert mode in TEMPLATES + assert name in TEMPLATES[mode] + assert TEMPLATES[mode][name] + + +def test_all_descriptions_exist(): + for name in ("basic", "melody", "chord", "drum", "empty"): + assert name in DESCRIPTIONS + assert DESCRIPTIONS[name] + + +def test_get_template_basic(): + mml, desc = get_template("ppmck", "basic") + assert mml + assert desc == "基本的な4ch構成(メロディ+和音+ベース+リズム)" + + +def test_get_template_melody(): + mml, desc = get_template("pyxel", "melody") + assert mml + assert desc == "メロディ重視(Pulse1主旋律、他は伴奏最小限)" + + +def test_get_template_chord(): + mml, desc = get_template("ppmck", "chord") + assert mml + assert desc == "コード伴奏重視(Pulse2で和音、Triangleでベース)" + + +def test_get_template_drum(): + mml, desc = get_template("pyxel", "drum") + assert mml + assert desc == "リズム重視(Noise中心のビートパターン)" + + +def test_get_template_empty(): + mml, desc = get_template("ppmck", "empty") + assert mml + assert desc == "各チャンネルのヘッダーのみ(空のテンプレート)" + + +@pytest.mark.parametrize("mode", ["ppmck", "pyxel"]) +@pytest.mark.parametrize("template", ["basic", "melody", "chord", "drum", "empty"]) +def test_template_validates(mode, template): + mml, _ = get_template(mode, template) + result = compose_mml(action="validate", mml=mml, mode=mode) + assert result["valid"] is True, f"{mode}/{template} invalid: {result['errors']}" + + +def test_template_ppmck_has_headers(): + mml, _ = get_template("ppmck", "basic") + assert "#TITLE" in mml + + +def test_template_pyxel_has_track_headers(): + mml, _ = get_template("pyxel", "basic") + assert "0:" in mml + assert "1:" in mml + assert "2:" in mml + assert "3:" in mml + + +def test_template_empty_has_rests(): + mml, _ = get_template("ppmck", "empty") + # Even empty template should have rests (not truly empty) + assert "r" in mml.lower() + + +def test_template_invalid_name_falls_back(): + result = compose_mml(action="template", mode="ppmck", template="nonexistent") + assert result["mml"] + assert result["description"] |
