Compare commits

...

2 Commits

Author SHA1 Message Date
Devin AI
ee335c7862 Improve test documentation and coverage for LLM import
Co-Authored-By: Joe Moura <joao@crewai.com>
2025-03-13 01:13:14 +00:00
Devin AI
6be47ee64e Fix issue #2353: Add tests for importing LLM from crewai
Co-Authored-By: Joe Moura <joao@crewai.com>
2025-03-13 01:07:01 +00:00

65
tests/test_import_llm.py Normal file
View File

@@ -0,0 +1,65 @@
"""Tests for LLM import functionality."""
import pytest
@pytest.fixture
def bedrock_model_path():
"""Fixture providing the standard Bedrock model path for testing."""
return "bedrock/anthropic.claude-3-sonnet-20240229-v1:0"
def test_import_llm_from_crewai():
"""
Test LLM import functionality from crewai package.
Verifies:
- Direct import of LLM class from crewai package
- Import statement succeeds without raising exceptions
"""
try:
from crewai import LLM
assert LLM is not None
except ImportError as e:
pytest.fail(f"Failed to import LLM from crewai: {e}")
def test_bedrock_llm_creation(bedrock_model_path):
"""
Test that a Bedrock LLM can be created with the correct model.
Verifies:
- LLM can be instantiated with a Bedrock model
- The model property is correctly set to the Bedrock model path
- No exceptions are raised during instantiation
"""
try:
from crewai import LLM
# Just test the object creation, not the actual API call
bedrock_llm = LLM(model=bedrock_model_path)
assert bedrock_llm is not None
assert bedrock_llm.model == bedrock_model_path
except Exception as e:
pytest.fail(f"Failed to create Bedrock LLM: {e}")
def test_llm_with_invalid_model():
"""
Test LLM creation with an invalid model name format.
Verifies:
- LLM can be instantiated with any model string
- No validation errors occur during instantiation
- The model property is correctly set to the provided string
"""
try:
from crewai import LLM
invalid_model = "invalid-model-name"
llm = LLM(model=invalid_model)
assert llm is not None
assert llm.model == invalid_model
except Exception as e:
pytest.fail(f"Failed to create LLM with invalid model: {e}")