36 lines
982 B
Python
36 lines
982 B
Python
"""Zones may hold both presets and sequences."""
|
|
|
|
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_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:
|
|
json.dump({}, f)
|
|
z = Zone()
|
|
z.file = path
|
|
z.clear()
|
|
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.get("sequence_ids") == ["seq1"]
|
|
preset_ids = Zone._preset_ids_in_doc(doc)
|
|
assert "p1" in preset_ids
|
|
assert "p2" in preset_ids
|