mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 16:18:30 +00:00
Fix lint issues in test script
- Use crew variable to avoid F841 unused variable error - Remove API key logging to address CodeQL security alert - Make path portable using os.path.join Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -3,17 +3,22 @@
|
||||
Test script for issue #3559 - TraceBatchManager authentication handling
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, '/home/ubuntu/repos/crewAI/src')
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
|
||||
|
||||
def test_tracing_auth_issue():
|
||||
"""Test that tracing authentication issue is fixed"""
|
||||
|
||||
try:
|
||||
from crewai.events.listeners.tracing.trace_batch_manager import TraceBatchManager
|
||||
from crewai.cli.authentication.token import AuthError
|
||||
from unittest.mock import patch
|
||||
|
||||
from crewai.cli.authentication.token import AuthError
|
||||
from crewai.events.listeners.tracing.trace_batch_manager import (
|
||||
TraceBatchManager,
|
||||
)
|
||||
|
||||
print("Test 1: TraceBatchManager creation without authentication")
|
||||
|
||||
with patch(
|
||||
@@ -21,7 +26,7 @@ def test_tracing_auth_issue():
|
||||
side_effect=AuthError("No token found, make sure you are logged in")
|
||||
):
|
||||
batch_manager = TraceBatchManager()
|
||||
print(f"✓ TraceBatchManager created successfully with empty API key: '{batch_manager.plus_api.api_key}'")
|
||||
print("✓ TraceBatchManager created successfully with empty API key")
|
||||
|
||||
batch = batch_manager.initialize_batch({"user_id": "test"}, {"crew_name": "test"})
|
||||
if batch is not None:
|
||||
@@ -37,7 +42,7 @@ def test_tracing_auth_issue():
|
||||
return False
|
||||
|
||||
try:
|
||||
from crewai import Agent, Crew, Task, LLM
|
||||
from crewai import LLM, Agent, Crew, Task
|
||||
|
||||
print("\nTest 2: Crew creation without authentication")
|
||||
|
||||
@@ -64,7 +69,7 @@ def test_tracing_auth_issue():
|
||||
verbose=False
|
||||
)
|
||||
|
||||
print("✓ Crew created successfully without authentication errors")
|
||||
print(f"✓ Crew created successfully without authentication errors: {len(crew.agents)} agents, {len(crew.tasks)} tasks")
|
||||
|
||||
except Exception as e:
|
||||
print(f"✗ Crew creation test failed: {e}")
|
||||
|
||||
Reference in New Issue
Block a user