File size: 1,886 Bytes
3b9a6b5
 
 
 
 
 
 
 
 
 
 
5e08aa9
3b9a6b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import pytest, logging

from src.utils.load_secrets import load_secrets

# Configure logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

# Load environment variables
load_secrets("tests/secrets/creds.py")
# Import task_composer_agent after environment variables are set
from src.factory.agents.task_composer_agent import TaskComposerAgent


@pytest.mark.asyncio
async def test_task_composer_agent():
    logger.info("\n=== Test Environment ===")

    logger.info("\n=== Starting Test ===")

    # Create agent
    logger.info("\nInitializing task_composer_agent...")
    agent = TaskComposerAgent()

    # Test input
    test_input = "Plan a weekend trip to Paris"
    logger.info(f"\n=== Test Input ===")
    logger.info(f"Task: {test_input}")

    # Run workflow
    logger.info("\n=== Running Workflow ===")
    result = await agent.run_workflow(test_input)

    # Print the result
    logger.info(f"\n=== Final Result ===")
    logger.info("Task breakdown with estimated times:")
    for task, duration, skill in result:
        logger.info(f"- {task}: {duration} units (Skill: {skill})")

    # Calculate total time
    total_time = sum(
        int(time) if str(time).isdigit() and str(time) != "" else 0
        for _, time, _ in result
    )
    logger.info(
        f"\nTotal estimated time: {total_time} units ({total_time * 30} minutes)"
    )

    # Verify the result is a list of 3-tuples
    assert isinstance(result, list), f"Expected a list, got {type(result)}"
    assert all(
        isinstance(item, tuple) and len(item) == 3 for item in result
    ), "Expected a list of (task, duration, skill) tuples"
    logger.info("\n=== Test Summary ===")
    logger.info("βœ“ Test passed!")
    logger.info(f"βœ“ Task: {test_input}")
    logger.info(
        f"βœ“ Total estimated time: {total_time} units ({total_time * 30} minutes)"
    )