23 lines
801 B
Python
23 lines
801 B
Python
from datetime import date
|
|
|
|
from sqlmodel import Session
|
|
|
|
from innercontext.api.llm_context import build_user_profile_context
|
|
from innercontext.models import SexAtBirth, UserProfile
|
|
|
|
|
|
def test_build_user_profile_context_without_data(session: Session):
|
|
ctx = build_user_profile_context(session, reference_date=date(2026, 3, 5))
|
|
assert ctx == "USER PROFILE: no data\n"
|
|
|
|
|
|
def test_build_user_profile_context_with_data(session: Session):
|
|
profile = UserProfile(birth_date=date(1990, 3, 20), sex_at_birth=SexAtBirth.FEMALE)
|
|
session.add(profile)
|
|
session.commit()
|
|
|
|
ctx = build_user_profile_context(session, reference_date=date(2026, 3, 5))
|
|
assert "USER PROFILE:" in ctx
|
|
assert "Age: 35" in ctx
|
|
assert "Birth date: 1990-03-20" in ctx
|
|
assert "Sex at birth: female" in ctx
|