test_diarize_errors.py
Language Python978 B29 lines
"""Hugging Face access errors become instructions, not tracebacks."""from transcription_pipeline.diarize import DEFAULT_MODEL as MODELfrom transcription_pipeline.diarize import explain_load_errorclass GatedRepoError(Exception):passdef test_gated_model_says_where_to_accept_the_terms():e = explain_load_error(GatedRepoError("403 Client Error. Cannot access gated repo"), MODEL)assert e is not Noneassert "has not accepted the terms" in str(e)assert f"https://huggingface.co/{MODEL}" in str(e)def test_matches_the_message_too():e = explain_load_error(RuntimeError("you are not in the authorized list"), MODEL)assert e is not None and "accept" in str(e)def test_bad_token():e = explain_load_error(RuntimeError("401 Client Error: Invalid credentials"), MODEL)assert e is not None and "rejected the token" in str(e)def test_other_errors_pass_through():assert explain_load_error(OSError("disk full"), MODEL) is None