"""
集成测试 - 端到端流程测试
"""
import sys
sys.path.insert(0, "/root/.skillhub/gift-advisor")

from src.api import GiftAdvisor, recommend_gift, parse_and_recommend

def test_basic_recommend():
    """测试基础推荐"""
    result = recommend_gift("妈妈", "生日", 200, 1000)
    assert result["success"] is True
    assert result["count"] > 0
    assert len(result["recommendations"]) > 0

def test_parse_and_recommend():
    """测试自然语言解析推荐"""
    result = parse_and_recommend("送妈妈的生日礼物，预算500元左右", enhanced=False)
    assert result["success"] is True
    if "query" in result:
        assert result["query"]["relation"] == "妈妈"
        assert result["query"]["occasion"] == "生日"

def test_recommend_structure():
    """测试推荐结果结构"""
    result = recommend_gift("女友", "情人节", 300, 2000)
    assert "recommendations" in result
    assert "blessing" in result
    for gift in result["recommendations"]:
        assert "name" in gift
        assert "price" in gift
        assert "reason" in gift
        assert "score" in gift

def test_budget_filter():
    """测试预算过滤"""
    result = recommend_gift("朋友", "生日", 100, 300)
    for gift in result["recommendations"]:
        assert gift["price"] >= 100
        assert gift["price"] <= 300

def test_blessing_generation():
    """测试祝福语生成"""
    result = recommend_gift("妈妈", "生日", 200, 1000)
    assert len(result["blessing"]) > 0

def test_advisor_class():
    """测试GiftAdvisor类"""
    advisor = GiftAdvisor()
    result = advisor.recommend("爸爸", "生日", 300, 1500)
    assert result["success"] is True
