Phase 11
This commit is contained in:
commit
c5bcb95d74
172 files changed
+9487
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import csv
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from src.config_loader import TurnLoggingSettings
|
||||
from src.models import TurnEvent, TurnFrameResult, TurnTrackState
|
||||
from src.turn_logger import TurnLogger
|
||||
|
||||
|
||||
def test_three_turn_logs_bom_json_and_summary_deduplication(tmp_path: Path) -> None:
|
||||
logger = TurnLogger(TurnLoggingSettings(True, True, True, True, 1, str(tmp_path)), "exp", "stamp")
|
||||
logger.open()
|
||||
frame = TurnFrameResult(1, 2, "now", .2, True, True, True, 0, 25, 25, 25,
|
||||
"positive", True, True, "weak", .3)
|
||||
event = TurnEvent("turn_confirmed", 1, 2, "now", .2, 25, 25, "weak", {"注記": "反応"})
|
||||
state = TurnTrackState(1, total_frames=5, pose_frames=5, face_detected_frames=5,
|
||||
baseline_yaw=0, baseline_acquired=True, turn_confirmed=True,
|
||||
turn_level="weak", evaluable=True, valid_for_turn_analysis=True,
|
||||
exclusion_reason="turn_detected", finalized=True)
|
||||
logger.write_frames([frame])
|
||||
logger.write_events([event])
|
||||
logger.write_summary(state)
|
||||
logger.write_summary(state)
|
||||
logger.close(); logger.close()
|
||||
paths = list(tmp_path.glob("*.csv"))
|
||||
assert len(paths) == 3 and all(path.read_bytes().startswith(b"\xef\xbb\xbf") for path in paths)
|
||||
with next(path for path in paths if "events" in path.name).open(encoding="utf-8-sig", newline="") as stream:
|
||||
assert json.loads(next(csv.DictReader(stream))["metadata_json"])["注記"] == "反応"
|
||||
with next(path for path in paths if "summary" in path.name).open(encoding="utf-8-sig", newline="") as stream:
|
||||
assert len(list(csv.DictReader(stream))) == 1
|
||||
Reference in new issue
Block a user