fix(api): align zone content kind validation with model

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-08 10:33:42 +12:00
parent aab62efd4f
commit cb9758b97b
2 changed files with 18 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
"""Zone content_kind is fixed after create."""
"""Zones may hold both presets and sequences."""
import json
import os
@@ -12,7 +12,7 @@ sys.path.insert(0, str(PROJECT_ROOT / "src"))
from models.zone import Zone # noqa: E402
def test_update_cannot_change_content_kind():
def test_zone_presets_and_sequences_can_coexist():
with tempfile.TemporaryDirectory() as tmp:
path = os.path.join(tmp, "zone.json")
with open(path, "w", encoding="utf-8") as f:
@@ -20,8 +20,16 @@ def test_update_cannot_change_content_kind():
z = Zone()
z.file = path
z.clear()
zid = z.create("preset zone", group_ids=[], content_kind="presets")
z.update(zid, {"content_kind": "sequences", "name": "preset zone"})
zid = z.create("mixed zone", group_ids=[], content_kind="presets")
z.update(
zid,
{
"presets": [["p1", "p2"]],
"sequence_ids": ["seq1"],
},
)
doc = z.read(zid)
assert doc["content_kind"] == "presets"
assert doc.get("sequence_ids") == []
assert doc.get("sequence_ids") == ["seq1"]
preset_ids = Zone._preset_ids_in_doc(doc)
assert "p1" in preset_ids
assert "p2" in preset_ids