You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

26 lines
1.3 KiB

import csv
from pathlib import Path
from src.config_loader import VoiceLoggingSettings
from src.models import VoicePromptDecision, VoicePromptEvent, VoicePromptTrackState
from src.voice_logger import VoiceLogger
def test_voice_csvs_bom_json_control_and_dedup(tmp_path: Path) -> None:
config = VoiceLoggingSettings(True, True, True, True, 1, str(tmp_path))
logger = VoiceLogger(config, "exp", "stamp")
logger.open()
logger.write_decisions([VoicePromptDecision(1, 2, "t", 1., "control", True, True, False, True, "pseudo", None)])
logger.write_events([VoicePromptEvent("pseudo_prompt_triggered", 1, 2, "t", 1., "control",
pseudo_prompt=True, metadata={"日本語": "声掛けなし"})])
state = VoicePromptTrackState(1, "control", eligible=True, pseudo_prompt=True, finalized=True)
logger.write_summary(state)
logger.write_summary(state)
logger.close()
logger.close()
for path in tmp_path.glob("*.csv"):
assert path.read_bytes().startswith(b"\xef\xbb\xbf")
event_text = (tmp_path / "stamp_exp_voice_events.csv").read_text(encoding="utf-8-sig")
assert "日本語" in event_text and "声掛けなし" in event_text
with (tmp_path / "stamp_exp_voice_summary.csv").open(encoding="utf-8-sig", newline="") as stream:
assert len(list(csv.DictReader(stream))) == 1