mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
docs: Add comments and expand test coverage
- Add documentation comments for MODEL env var - Expand test coverage for Azure MODEL env var - Add test for missing MODEL env var case Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -22,19 +22,33 @@ from crewai.utilities.events import Emitter
|
||||
|
||||
|
||||
def test_agent_azure_model_env_var():
|
||||
"""Test Azure MODEL environment variable handling with various cases."""
|
||||
# Store original environment variables
|
||||
original_model = os.environ.get("MODEL")
|
||||
|
||||
# Test with uppercase MODEL
|
||||
os.environ["MODEL"] = "azure/test-model"
|
||||
test_cases = [
|
||||
("azure/test-model", "azure/test-model"), # Valid case
|
||||
("azure/minimal", "azure/minimal"), # Another valid case
|
||||
]
|
||||
|
||||
for input_model, expected_model in test_cases:
|
||||
# Set test MODEL value
|
||||
os.environ["MODEL"] = input_model
|
||||
agent = Agent(role="test role", goal="test goal", backstory="test backstory")
|
||||
assert agent.llm.model == expected_model
|
||||
|
||||
# Test missing MODEL env var
|
||||
if "MODEL" in os.environ:
|
||||
del os.environ["MODEL"]
|
||||
agent = Agent(role="test role", goal="test goal", backstory="test backstory")
|
||||
assert agent.llm.model == "azure/test-model"
|
||||
assert agent.llm.model == "gpt-4o-mini" # Default model
|
||||
|
||||
# Clean up environment variables
|
||||
if original_model:
|
||||
os.environ["MODEL"] = original_model
|
||||
else:
|
||||
del os.environ["MODEL"]
|
||||
if "MODEL" in os.environ:
|
||||
del os.environ["MODEL"]
|
||||
|
||||
|
||||
def test_agent_llm_creation_with_env_vars():
|
||||
|
||||
Reference in New Issue
Block a user