sipp-rs 0.1.4

Unified Rust library for extensible Sipp inference
//! Tests the `runtime::inference_runtime::native` module in
//! `sipp`.
//!
//! Covers empty native-runtime convenience paths with fake handles, including
//! scalar token defaults and model-free RuntimeNotReady error propagation.

use crate::error::Error;
use crate::runtime::config::NativeRuntimeConfig;
use crate::runtime::inference_runtime::runtime_tests::test_runtime;

#[test]
fn empty_runtime_returns_empty_bos_and_eos_text_without_native_lookup() {
    let runtime = test_runtime(NativeRuntimeConfig::default());

    assert_eq!(runtime.get_bos_text().expect("bos text"), "");
    assert_eq!(runtime.get_eos_text().expect("eos text"), "");
}

#[test]
fn empty_runtime_template_methods_report_not_ready() {
    let runtime = test_runtime(NativeRuntimeConfig::default());

    assert!(matches!(
        runtime.chat_template_source(),
        Err(Error::RuntimeNotReady)
    ));
    assert!(matches!(
        runtime.apply_chat_template_json("[]", true),
        Err(Error::RuntimeNotReady)
    ));
    assert!(matches!(
        runtime.parse_asr_output("en", "transcript"),
        Err(Error::RuntimeNotReady)
    ));
}

#[test]
fn empty_runtime_rejects_speech_enqueue_before_allocating_a_request() {
    let mut runtime = test_runtime(NativeRuntimeConfig::default());

    assert!(matches!(
        runtime.enqueue_speech_request("hello", Some("en"), None, None),
        Err(Error::RuntimeNotReady)
    ));
    assert!(runtime.active_speech.is_none());
    assert!(!runtime.request_queue.has_uncompleted_requests());
}