evasion-annotator / tests /test_study.py
gmarti's picture
Deploy repair-aware randomized annotation study
5b34fc5 verified
Raw
History Blame Contribute Delete
2.4 kB
from app import study
def _eligible_form() -> dict:
form = {
"gate": "substantive_answer_attempt",
"gate_confidence": "82",
"gate_confidence_touched": "1",
"responsiveness": "71",
"responsiveness_touched": "1",
"rasiah": "intermediate",
"supplied_information": "most",
"confidence": "77",
"confidence_touched": "1",
"rationale": "The response addresses the forecast but leaves the requested range unresolved.",
"response_time_ms": "43000",
"audio_played_ms": "18000",
"audio_completed": "1",
"audio_revision": "less_responsive",
"audible_event": "pause",
}
for descriptor in study.DESCRIPTORS:
form[f"descriptor_{descriptor.value}"] = "3"
return form
def test_complete_text_audio_response_validates() -> None:
clean, error = study.validate_submission(_eligible_form(), "text_audio", 20)
assert error is None
assert clean["responsiveness"] == 71
assert clean["audio_revision"] == "less_responsive"
def test_text_only_does_not_accept_audio_retrospective_fields_as_required() -> None:
form = _eligible_form()
form.pop("audio_revision")
form.pop("audible_event")
form["audio_played_ms"] = "0"
form["audio_completed"] = "0"
clean, error = study.validate_submission(form, "text_only")
assert error is None
assert clean["audio_revision"] is None
def test_untouched_slider_is_rejected() -> None:
form = _eligible_form()
form["responsiveness_touched"] = "0"
assert study.validate_submission(form, "text_audio")[1] == "complete_scales"
def test_audio_must_be_played() -> None:
form = _eligible_form()
form["audio_played_ms"] = "0"
form["audio_completed"] = "0"
assert study.validate_submission(form, "text_audio", 20)[1] == "play_audio"
def test_repair_gate_skips_evasion_questions_but_keeps_rationale() -> None:
form = {
"gate": "clarification_repair",
"gate_confidence": "91",
"gate_confidence_touched": "1",
"rationale": "The executive asks the analyst to clarify the intended comparison.",
"audio_played_ms": "12000",
"audio_completed": "1",
}
clean, error = study.validate_submission(form, "text_audio")
assert error is None
assert clean["rasiah"] is None
assert clean["gate"] == "clarification_repair"