WalkXR-AI / tests / test_roleplay_agent.py
test_roleplay_agent.py
Raw

"""
Integration test for the Small Moments agent using a local Ollama setup.

This test exercises the LangGraph flow built is tasks T003.3 and T003.4.

To run this test, enter the following code in the terminal:
    .venv/bin/pip install pytest                                (if not already installed)
    .venv/bin/pip install ollama                                (if not already installed)
    PYTHONPATH=src pytest tests/test_roleplay_agent.py -q -s
"""

from walkxr_ai.agents.small_moments_roleplay_agent import SmallMomentsRoleplayAgent


def test_roleplay_agent() -> None:
    # Instantiate the agent
    # Initializes persona/retrieval engine/Ollama model and builds LangGraph initial state
    agent = SmallMomentsRoleplayAgent()

    # Run the LangGraph flow and print the final response
    result = agent.get_response(
        user_input="Hello, I am feeling a little nervous today.",
        history=[],
        user_id="test_user",
        session_id="test_session",
        stage="conversation",
    )
    print(result)
    
    # Basic assertions to verify the structure of the response
    assert isinstance(result, dict)                   # Is the result a dictionary?
    assert "debug" in result                          # Does the debug info exist?
    assert isinstance(result["debug"], dict)          # Is the debug info a dictionary?
    assert result["debug"].get("error") is None       # Do any errors occur?
    assert "response_text" in result                  # Does the response exist?
    assert isinstance(result["response_text"], str)   # Is the response text a string?
    assert result["response_text"].strip()            # Is the response non-empty?