MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / test_legacy_start_session_compatibility

Function test_legacy_start_session_compatibility

tests/unit/test_session.py:235–258  ·  view source on GitHub ↗

Test that legacy start_session still works and calls tracer.start_trace

(mock_tracing_core, mock_api_client, mock_trace_context, reset_client)

Source from the content-addressed store, hash-verified

233
234
235def test_legacy_start_session_compatibility(mock_tracing_core, mock_api_client, mock_trace_context, reset_client):
236 """Test that legacy start_session still works and calls tracer.start_trace"""
237 import agentops
238 from agentops.legacy import Session
239
240 # Initialize AgentOps
241 agentops.init(api_key="test-api-key", auto_start_session=False)
242
243 # Reset the call count to start fresh
244 mock_tracing_core.reset_mock()
245 # Mock the start_trace method
246 mock_tracing_core.start_trace.return_value = mock_trace_context
247
248 # Start a legacy session
249 session = agentops.start_session(tags=["legacy_test"])
250
251 # Verify the session was created
252 assert isinstance(session, Session)
253 # Check that the session's trace_context has the expected properties
254 assert session.trace_context is not None
255
256 # Verify that tracer.start_trace was called
257 # Note: May be called multiple times due to initialization
258 assert mock_tracing_core.start_trace.call_count >= 1
259
260
261def test_legacy_end_session_compatibility(mock_tracing_core, mock_api_client, mock_trace_context, reset_client):

Callers

nothing calls this directly

Calls 2

initMethod · 0.80
start_sessionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…