Spaces:
Sleeping
Sleeping
File size: 896 Bytes
c42fe7e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import json
from pathlib import Path
import tempfile
from webapp.services.parsing.ds_builder import build_ds_from_notes
def test_build_ds_from_notes_basic():
# Arrange
notes = [
{"pitch": "C4", "duration": 1.0, "phoneme": "k"},
{"pitch": "D4", "duration": 0.5, "phoneme": "d"},
{"pitch": "E4", "duration": 0.75, "phoneme": "e"},
]
with tempfile.TemporaryDirectory() as tmpdir:
output_path = Path(tmpdir) / "test.ds"
# Act
build_ds_from_notes(notes, output_path)
# Assert
with open(output_path, "r", encoding="utf-8") as f:
ds = json.load(f)
assert ds["ph_seq"] == "k d e"
assert ds["ph_num"] == "1 1 1"
assert ds["note_seq"] == "C4 D4 E4"
assert ds["note_dur"] == "1.0 0.5 0.75"
assert ds["note_slur"] == "0 0 0"
assert ds["input_type"] == "phoneme"
|