pltobing's picture
chore(repo): finalize licensing and documentation
51e84d2
Raw History Blame Contribute Delete
2 kB
# License: Apache-2.0 License
# Created by: Patrick Lumbantobing, VertoX-AI
# Copyright (c) 2026 VertoX-AI. All rights reserved.
#
# This work is licensed under the Apache-2.0 License.
# To view a copy of this license, visit
# https://www.apache.org/licenses/LICENSE-2.0
from __future__ import annotations
import pytest
from speech_text_data_aligners.core.errors import (
AlignmentValidationError,
AudioError,
BackendExecutionError,
BackendOutputError,
BackendUnavailableError,
BenchmarkError,
ConfigurationError,
MetadataError,
SpeechTextAlignerError,
TranscriptError,
TranscriptMappingError,
failure_from_error,
)
@pytest.mark.parametrize(
("error_type", "code", "category"),
[
(ConfigurationError, "configuration_error", "configuration"),
(MetadataError, "metadata_error", "metadata"),
(AudioError, "audio_error", "audio"),
(TranscriptError, "transcript_error", "transcript"),
(BackendUnavailableError, "backend_unavailable", "backend"),
(BackendExecutionError, "backend_execution_error", "backend"),
(BackendOutputError, "backend_output_error", "backend"),
(TranscriptMappingError, "transcript_mapping_error", "mapping"),
(AlignmentValidationError, "alignment_validation_error", "validation"),
(BenchmarkError, "benchmark_error", "benchmark"),
],
)
def test_error_taxonomy_has_stable_codes(
error_type: type[SpeechTextAlignerError], code: str, category: str
) -> None:
error = error_type("safe", context=(("row", 1),), retryable=True)
failure = failure_from_error(error, request_id="000001")
assert (failure.code, failure.category, failure.message, failure.retryable) == (
code,
category,
"safe",
True,
)
def test_base_error_is_an_exception() -> None:
error = SpeechTextAlignerError("message")
assert str(error) == "message"
assert error.context == ()
assert not error.retryable