mattrguerra/transcription-pipelinemainPrivate on GitHub, published here in full

test_diarize_errors.py

Language Python978 B29 lines

tests/test_diarize_errors.py

  1. """Hugging Face access errors become instructions, not tracebacks."""
  2. from transcription_pipeline.diarize import DEFAULT_MODEL as MODEL
  3. from transcription_pipeline.diarize import explain_load_error
  4. class GatedRepoError(Exception):
  5. pass
  6. def test_gated_model_says_where_to_accept_the_terms():
  7. e = explain_load_error(GatedRepoError("403 Client Error. Cannot access gated repo"), MODEL)
  8. assert e is not None
  9. assert "has not accepted the terms" in str(e)
  10. assert f"https://huggingface.co/{MODEL}" in str(e)
  11. def test_matches_the_message_too():
  12. e = explain_load_error(RuntimeError("you are not in the authorized list"), MODEL)
  13. assert e is not None and "accept" in str(e)
  14. def test_bad_token():
  15. e = explain_load_error(RuntimeError("401 Client Error: Invalid credentials"), MODEL)
  16. assert e is not None and "rejected the token" in str(e)
  17. def test_other_errors_pass_through():
  18. assert explain_load_error(OSError("disk full"), MODEL) is None