"""
Test de la nouvelle fonction get_holdings_detail.
"""
import os
import sys
import asyncio
# Force UTF-8 encoding for Windows console
if sys.platform == 'win32':
import io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
os.environ['DB_PATH'] = r'C:\Users\miche\AppData\Roaming\com.teymz.wealthfolio\app.db'
from mcp_server import call_tool
async def test_holdings_detail():
print("="*80)
print("TEST: get_holdings_detail() - Liste détaillée des positions")
print("="*80)
result = await call_tool("get_holdings_detail", {})
print(result[0].text)
# Vérifications
text = result[0].text
assert "DÉTAIL DES POSITIONS" in text
assert "Valeur totale" in text
assert "ANALYSE DE DIVERSIFICATION" in text
print("\n✓ Test réussi!")
if __name__ == "__main__":
asyncio.run(test_holdings_detail())