48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
import asyncio
|
|
import sys
|
|
import os
|
|
|
|
sys.path.append(os.getcwd())
|
|
|
|
from app.services import markdown_tools
|
|
from app.config import settings
|
|
|
|
async def test_tools():
|
|
print("Testing Text Tools...")
|
|
|
|
# 1. Test Mermaid Rendering
|
|
print("\n1. Testing Mermaid Rendering...")
|
|
try:
|
|
code = "graph TD; A-->B;"
|
|
result = await markdown_tools.render_mermaid(code, output_format="svg")
|
|
if result.get("success"):
|
|
print(" [SUCCESS] Mermaid Rendered")
|
|
print(f" URL: {result.get('url')}")
|
|
if 'image_url' in result:
|
|
print(" [VERIFIED] 'image_url' key present")
|
|
else:
|
|
print(" [FAILED] 'image_url' key MISSING")
|
|
else:
|
|
print(f" [FAILED] {result.get('error')}")
|
|
except Exception as e:
|
|
print(f" [ERROR] {e}")
|
|
|
|
# 2. Test Markdown Conversion
|
|
print("\n2. Testing Markdown Conversion...")
|
|
try:
|
|
md_content = "# Hello\n\n* List item"
|
|
result = await markdown_tools.convert_markdown(md_content, output_format="html")
|
|
if result.get("success"):
|
|
print(" [SUCCESS] Markdown Converted")
|
|
print(f" Preview: {result.get('content')[:50]}...")
|
|
if 'output' in result:
|
|
print(" [VERIFIED] 'output' key present")
|
|
else:
|
|
print(" [FAILED] 'output' key MISSING")
|
|
else:
|
|
print(f" [FAILED] {result.get('error')}")
|
|
except Exception as e:
|
|
print(f" [ERROR] {e}")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(test_tools())
|