120 lines
3.3 KiB
Python
120 lines
3.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to verify FLUX.1 Edit MCP Server fixes
|
|
This script tests if the Unicode and JSON parsing issues are resolved
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# Add src to path for imports
|
|
sys.path.insert(0, str(Path(__file__).parent / 'src'))
|
|
|
|
def test_console_encoding():
|
|
"""Test console encoding with safe characters"""
|
|
print("Testing console output with safe characters...")
|
|
print("[OK] ASCII characters work fine")
|
|
print("[ERROR] Error messages use brackets instead of Unicode")
|
|
print("[SUCCESS] Success messages use brackets instead of Unicode")
|
|
print("[INFO] Info messages work properly")
|
|
return True
|
|
|
|
def test_dependency_imports():
|
|
"""Test importing dependencies silently"""
|
|
print("Testing dependency imports...")
|
|
|
|
missing_deps = []
|
|
|
|
try:
|
|
import aiohttp
|
|
# Silent check
|
|
except ImportError:
|
|
missing_deps.append("aiohttp")
|
|
|
|
try:
|
|
import mcp
|
|
# Silent check
|
|
except ImportError:
|
|
missing_deps.append("mcp")
|
|
|
|
try:
|
|
from src.connector import Config
|
|
# Silent check
|
|
except ImportError:
|
|
missing_deps.append("src.connector.Config")
|
|
|
|
try:
|
|
from src.server import main
|
|
# Silent check
|
|
except ImportError:
|
|
missing_deps.append("src.server.main")
|
|
|
|
if missing_deps:
|
|
print(f"[ERROR] Missing dependencies: {', '.join(missing_deps)}")
|
|
return False
|
|
else:
|
|
print("[SUCCESS] All imports successful")
|
|
return True
|
|
|
|
def test_server_creation():
|
|
"""Test creating server instance without starting it"""
|
|
print("Testing server creation...")
|
|
|
|
try:
|
|
from src.server import create_server
|
|
server = create_server()
|
|
print("[SUCCESS] Server instance created successfully")
|
|
return True
|
|
except Exception as e:
|
|
print(f"[ERROR] Server creation failed: {e}")
|
|
return False
|
|
|
|
def main():
|
|
"""Main test function"""
|
|
print("FLUX.1 Edit MCP Server - Fix Verification")
|
|
print("=" * 50)
|
|
|
|
# Set UTF-8 encoding environment variables
|
|
os.environ['PYTHONIOENCODING'] = 'utf-8'
|
|
os.environ['PYTHONUTF8'] = '1'
|
|
|
|
tests = [
|
|
("Console encoding", test_console_encoding),
|
|
("Dependency imports", test_dependency_imports),
|
|
("Server creation", test_server_creation),
|
|
]
|
|
|
|
passed = 0
|
|
total = len(tests)
|
|
|
|
for test_name, test_func in tests:
|
|
print(f"\nRunning test: {test_name}")
|
|
print("-" * 30)
|
|
|
|
try:
|
|
if test_func():
|
|
passed += 1
|
|
print(f"[PASSED] {test_name}")
|
|
else:
|
|
print(f"[FAILED] {test_name}")
|
|
except Exception as e:
|
|
print(f"[FAILED] {test_name}: {e}")
|
|
|
|
print("\n" + "=" * 50)
|
|
print(f"Test Results: {passed}/{total} tests passed")
|
|
|
|
if passed == total:
|
|
print("[SUCCESS] All tests passed! The fixes should work.")
|
|
print("\nTo run the server:")
|
|
print("1. Make sure your .env file is configured")
|
|
print("2. Run: start.bat or run.bat")
|
|
print("3. The server should start without Unicode errors")
|
|
return 0
|
|
else:
|
|
print(f"[FAILED] {total - passed} tests failed. Check the errors above.")
|
|
return 1
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|