Files
mediaproc/tests/detect/test_tracing.py
2026-03-30 07:22:14 -03:00

35 lines
995 B
Python

"""Tests for Langfuse tracing — works without Langfuse configured (no-op mode)."""
import pytest
from core.detect.tracing import trace_node, SpanContext, flush
def test_trace_node_noop():
"""Without LANGFUSE_SECRET_KEY, tracing is a no-op but doesn't error."""
state = {"job_id": "test-job", "profile_name": "soccer_broadcast"}
with trace_node(state, "extract_frames") as span:
assert isinstance(span, SpanContext)
span.set_output({"frames": 42})
assert span.metadata["frames"] == 42
assert span.metadata["status"] == "ok"
assert "duration_seconds" in span.metadata
def test_trace_node_error():
"""Span records error status on exception."""
state = {"job_id": "test-job"}
with pytest.raises(ValueError):
with trace_node(state, "bad_node") as span:
raise ValueError("boom")
assert span.metadata["status"] == "error"
def test_flush_noop():
"""Flush works when Langfuse is not configured."""
flush()