Skip to content

test_extra_overrides_routing

LTX-2 audio-conditioning kwargs must reach ForwardBatch.extra and SamplingParam.update() must reject unknown kwargs instead of silently dropping them.

Background: prior to PR-1288 a chain of LTX-2 audio kwargs (audio_num_frames, ltx2_audio_clean_latent …) silently flowed into SamplingParam.update() which logger.error'd and dropped them. That made every continuation segment generate audio for the default num_frames duration, which in turn fed an A/V duration mismatch into av_streaming.stream_fmp4 whose -shortest ffmpeg invocation closed stdin before the writer thread had pushed every frame, surfacing as BrokenPipeError in the streaming server.

These tests pin two contracts
  1. _BATCH_EXTRA_PASSTHROUGH_KEYS lists the exact set of kwargs pulled out of generate_video(**kwargs) for batch.extra.
  2. SamplingParam.update() raises ValueError on unknown keys.

Classes

Functions

fastvideo.tests.api.test_extra_overrides_routing.test_passthrough_keys_are_not_sampling_param_fields

test_passthrough_keys_are_not_sampling_param_fields() -> None

If any of these become SamplingParam fields, the routing block in video_generator.py needs to be re-evaluated — they would no longer need to be popped before sampling_param.update().

Source code in fastvideo/tests/api/test_extra_overrides_routing.py
def test_passthrough_keys_are_not_sampling_param_fields() -> None:
    """If any of these become SamplingParam fields, the routing block
    in video_generator.py needs to be re-evaluated — they would no
    longer need to be popped before ``sampling_param.update()``."""
    import dataclasses
    sp_fields = {f.name for f in dataclasses.fields(SamplingParam())}
    leaked = sp_fields & set(_BATCH_EXTRA_PASSTHROUGH_KEYS)
    assert not leaked, (
        f"Passthrough keys collide with SamplingParam fields: {leaked}. "
        "Remove from _BATCH_EXTRA_PASSTHROUGH_KEYS or rename the field.")

fastvideo.tests.api.test_extra_overrides_routing.test_sampling_param_update_error_mentions_passthrough_route

test_sampling_param_update_error_mentions_passthrough_route() -> None

The error message should point future contributors at the right routing mechanism so they don't re-introduce silent dropping.

Source code in fastvideo/tests/api/test_extra_overrides_routing.py
def test_sampling_param_update_error_mentions_passthrough_route() -> None:
    """The error message should point future contributors at the right
    routing mechanism so they don't re-introduce silent dropping."""
    sp = SamplingParam()
    with pytest.raises(ValueError, match="_BATCH_EXTRA_PASSTHROUGH_KEYS"):
        sp.update({"audio_num_frames": 161})

fastvideo.tests.api.test_extra_overrides_routing.test_sampling_param_update_rejects_audio_passthrough_keys

test_sampling_param_update_rejects_audio_passthrough_keys() -> None

LTX-2 audio kwargs must NOT slip through update() — they belong to ForwardBatch.extra and the routing block in video_generator.py is responsible for popping them first.

Source code in fastvideo/tests/api/test_extra_overrides_routing.py
def test_sampling_param_update_rejects_audio_passthrough_keys() -> None:
    """LTX-2 audio kwargs must NOT slip through ``update()`` — they
    belong to ``ForwardBatch.extra`` and the routing block in
    ``video_generator.py`` is responsible for popping them first."""
    sp = SamplingParam()
    for key in _BATCH_EXTRA_PASSTHROUGH_KEYS:
        with pytest.raises(ValueError, match="unknown field"):
            sp.update({key: object()})

fastvideo.tests.api.test_extra_overrides_routing.test_sampling_param_update_rejects_partially_unknown_keys

test_sampling_param_update_rejects_partially_unknown_keys() -> None

Even when most keys are valid, a single unknown key must raise. Partial-success was the silent-failure mode this regression fixes.

Source code in fastvideo/tests/api/test_extra_overrides_routing.py
def test_sampling_param_update_rejects_partially_unknown_keys() -> None:
    """Even when most keys are valid, a single unknown key must raise.
    Partial-success was the silent-failure mode this regression fixes."""
    sp = SamplingParam()
    with pytest.raises(ValueError, match=r"\['bogus_field'\]"):
        sp.update({"prompt": "hello", "bogus_field": 42})