npc-clients-python/tests/test_minimal.py

48 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""Minimal test to verify NPC chat functionality works"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from gumyum_npc_client import NPC, SpawnedData
def test_npc_structure():
"""Test basic NPC structure and chat proxy"""
# Create an NPC
npc = NPC(
npc_id=123,
name="Test",
profession="Tester",
personality_type=5,
spawned=SpawnedData(location="test", mood="happy", stress_level=0),
universe_id="test-universe",
seed=12345,
)
# Check basic properties
assert npc.npc_id == 123
assert npc.name == "Test"
assert hasattr(npc, "chat")
assert hasattr(npc, "completions")
# Check that chat proxy is created
assert npc.chat is not None
assert hasattr(npc.chat, "completions")
# Should fail without client
try:
import asyncio
asyncio.run(npc.chat.completions([{"role": "user", "content": "Hi"}]))
assert False, "Should have raised ValueError"
except ValueError as e:
assert "NPC has no client reference" in str(e)
print("✅ All checks passed!")
if __name__ == "__main__":
test_npc_structure()