phase 8
This commit is contained in:
34
tests/detect/test_tracing.py
Normal file
34
tests/detect/test_tracing.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""Tests for Langfuse tracing — works without Langfuse configured (no-op mode)."""
|
||||
|
||||
import pytest
|
||||
|
||||
from 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()
|
||||
Reference in New Issue
Block a user