CrewAI needs to access: agentops.track_agent agentops.track_tool agentops.start_session agentops.end_session agentops.ActionEvent agentops.ToolEvent
(mock_tracing_core, mock_api_client, mock_trace_context, reset_client)
| 475 | |
| 476 | |
| 477 | def test_crewai_backwards_compatibility(mock_tracing_core, mock_api_client, mock_trace_context, reset_client): |
| 478 | """ |
| 479 | CrewAI needs to access: |
| 480 | |
| 481 | agentops.track_agent |
| 482 | agentops.track_tool |
| 483 | agentops.start_session |
| 484 | agentops.end_session |
| 485 | agentops.ActionEvent |
| 486 | agentops.ToolEvent |
| 487 | """ |
| 488 | import agentops |
| 489 | from agentops.legacy import Session |
| 490 | |
| 491 | # Configure mocks |
| 492 | mock_tracing_core.start_trace.return_value = mock_trace_context |
| 493 | |
| 494 | # Test initialization with API key |
| 495 | agentops.init(api_key="test-api-key") |
| 496 | |
| 497 | # Test session management functions |
| 498 | session = agentops.start_session(tags=["test", "crewai"]) |
| 499 | assert isinstance(session, Session) |
| 500 | |
| 501 | # Test that passing a string to end_session doesn't raise an error |
| 502 | agentops.end_session("Success") # This pattern is used in CrewAI |
| 503 | |
| 504 | # Test track_agent function exists and doesn't raise errors |
| 505 | try: |
| 506 | # Mock an agent object similar to what CrewAI would provide |
| 507 | class MockAgent: |
| 508 | def __init__(self): |
| 509 | self.role = "Test Agent" |
| 510 | self.goal = "Testing" |
| 511 | self.id = "test-agent-id" |
| 512 | |
| 513 | agent = MockAgent() |
| 514 | agentops.track_agent(agent) |
| 515 | except Exception as e: |
| 516 | assert False, f"track_agent raised an exception: {e}" |
| 517 | |
| 518 | # Test track_tool function exists and doesn't raise errors |
| 519 | try: |
| 520 | # Mock a tool object similar to what CrewAI would provide |
| 521 | class MockTool: |
| 522 | def __init__(self): |
| 523 | self.name = "Test Tool" |
| 524 | self.description = "A test tool" |
| 525 | |
| 526 | tool = MockTool() |
| 527 | agentops.track_tool(tool, "Test Agent") |
| 528 | except Exception as e: |
| 529 | assert False, f"track_tool raised an exception: {e}" |
| 530 | |
| 531 | # Test events that CrewAI might use |
| 532 | tool_event = agentops.ToolEvent(name="test_tool") |
| 533 | action_event = agentops.ActionEvent(action_type="test_action") |
| 534 |
nothing calls this directly
no test coverage detected
searching dependent graphs…