"""Zone content_kind is fixed after create."""

import json
import os
import sys
import tempfile
from pathlib import Path

PROJECT_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(PROJECT_ROOT / "src"))

from models.zone import Zone  # noqa: E402


def test_update_cannot_change_content_kind():
    with tempfile.TemporaryDirectory() as tmp:
        path = os.path.join(tmp, "zone.json")
        with open(path, "w", encoding="utf-8") as f:
            json.dump({}, f)
        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"})
        doc = z.read(zid)
        assert doc["content_kind"] == "presets"
        assert doc.get("sequence_ids") == []
