speech-text-data-aligners / tests /unit /core /test_protocols.py
pltobing's picture
chore(repo): finalize licensing and documentation
51e84d2
Raw History Blame Contribute Delete
1.16 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
from speech_text_data_aligners.core.models import (
AlignmentOutcome,
AlignmentProvenance,
AlignmentRequest,
AlignmentResult,
)
from speech_text_data_aligners.core.protocols import AlignmentBackend
class FakeBackend:
@property
def name(self) -> str:
return "fake"
def align(self, request: AlignmentRequest) -> AlignmentResult:
return AlignmentResult(request.request_id, (), AlignmentProvenance("fake"))
def align_batch(
self, requests: tuple[AlignmentRequest, ...]
) -> tuple[AlignmentOutcome, ...]:
return tuple(
AlignmentOutcome(result=self.align(request)) for request in requests
)
def test_runtime_protocol_accepts_structural_backend() -> None:
assert isinstance(FakeBackend(), AlignmentBackend)
assert not isinstance(object(), AlignmentBackend)