"""测试商品知识库"""
import sys
sys.path.insert(0, "/root/.skillhub/gift-advisor")

from src.knowledge import KnowledgeBase

def test_knowledge_base_load():
    """测试知识库加载"""
    kb = KnowledgeBase()
    assert kb is not None

def test_get_scenarios_count():
    """测试场景数量>=50"""
    kb = KnowledgeBase()
    scenarios = kb.get_all_scenarios()
    assert len(scenarios) >= 50

def test_filter_by_relation():
    """测试按关系筛选"""
    kb = KnowledgeBase()
    results = kb.filter_scenarios(relation="妈妈")
    assert len(results) > 0
    for s in results:
        assert "妈妈" in s["relation"]

def test_filter_by_occasion():
    """测试按场合筛选"""
    kb = KnowledgeBase()
    results = kb.filter_scenarios(occasion="生日")
    assert len(results) > 0

def test_filter_by_budget():
    """测试按预算筛选"""
    kb = KnowledgeBase()
    results = kb.filter_scenarios(budget_min=100, budget_max=500)
    assert len(results) > 0

def test_get_gifts():
    """测试获取礼物"""
    kb = KnowledgeBase()
    gifts = kb.get_gifts("birthday_mom_practical")
    assert len(gifts) > 0
