Skip to main content
Glama

MCP-Blender

by shdann
test_enhanced_integration.py7.34 kB
#!/usr/bin/env python3 """ Test script for enhanced VeFrank-Blender integration Validates the complete pipeline from generation to visualization """ import asyncio import sys import time from pathlib import Path # Add parent directory to path sys.path.insert(0, str(Path(__file__).parent.parent)) from vefrank_blender_bridge import VeFrankBlenderBridge from utils.asset_generator_dynamic import list_available_components async def test_integration(): """Run comprehensive integration tests.""" print("VeFrank-Blender Enhanced Integration Test") print("=" * 60) bridge = VeFrankBlenderBridge() test_results = [] # Test 1: Component Discovery print("\nTest 1: Component Discovery") print("-" * 30) try: components = list_available_components() print(f"SUCCESS: Discovered {len(components)} component types") test_results.append(("Component Discovery", "PASS", len(components))) except Exception as e: print(f"FAIL: {e}") test_results.append(("Component Discovery", "FAIL", str(e))) # Test 2: Local Generation (No Tokens) print("\nTest 2: Zero-Token Generation") print("-" * 30) try: start_time = time.time() result = bridge.generate_component_locally("alternator") generation_time = (time.time() - start_time) * 1000 if result["status"] == "success": print(f"SUCCESS: Generated alternator in {generation_time:.1f}ms") print(f" Shape: {result['shape']}") print(f" Token Usage: {result['stats']['token_usage']}") test_results.append(("Zero-Token Generation", "PASS", f"{generation_time:.1f}ms")) else: print(f"FAIL: {result.get('message')}") test_results.append(("Zero-Token Generation", "FAIL", result.get('message'))) except Exception as e: print(f"FAIL: {e}") test_results.append(("Zero-Token Generation", "FAIL", str(e))) # Test 3: Blender Connection print("\nTest 3: Blender Connection") print("-" * 30) if bridge.is_blender_connected(): print("SUCCESS: Blender is connected") test_results.append(("Blender Connection", "PASS", "Connected")) # Test 4: Import to Blender print("\nTest 4: Import to Blender") print("-" * 30) try: obj_path = Path("../assets/3d_models/automotive/alternator.obj") if obj_path.exists(): result = await bridge.import_to_blender(str(obj_path), "test_alternator") if result.get("status") == "success": print("SUCCESS: Imported to Blender") test_results.append(("Import to Blender", "PASS", "Imported")) else: print(f"FAIL: {result.get('message')}") test_results.append(("Import to Blender", "FAIL", result.get('message'))) else: print("SKIP: OBJ file not found") test_results.append(("Import to Blender", "SKIP", "No OBJ file")) except Exception as e: print(f"FAIL: {e}") test_results.append(("Import to Blender", "FAIL", str(e))) # Test 5: Material Application print("\nTest 5: Material Application") print("-" * 30) try: result = await bridge.apply_materials("test_alternator", "aluminum") if result.get("status") == "success": print("SUCCESS: Applied aluminum material") test_results.append(("Material Application", "PASS", "Applied")) else: print(f"FAIL: {result.get('message')}") test_results.append(("Material Application", "FAIL", result.get('message'))) except Exception as e: print(f"FAIL: {e}") test_results.append(("Material Application", "FAIL", str(e))) else: print("INFO: Blender not connected - skipping Blender tests") print("To connect: Open Blender and start VeFrank server from sidebar") test_results.append(("Blender Connection", "SKIP", "Not connected")) # Test 6: Cache Performance print("\nTest 6: Cache Performance") print("-" * 30) try: # First generation (cache miss) start_time = time.time() result1 = bridge.generate_component_locally("pcm") time1 = (time.time() - start_time) * 1000 # Second generation (cache hit) start_time = time.time() result2 = bridge.generate_component_locally("pcm") time2 = (time.time() - start_time) * 1000 if time2 < time1 / 10: # Cache should be at least 10x faster print(f"SUCCESS: Cache working ({time1:.1f}ms -> {time2:.1f}ms)") test_results.append(("Cache Performance", "PASS", f"{time2:.1f}ms")) else: print(f"WARNING: Cache not optimal ({time1:.1f}ms -> {time2:.1f}ms)") test_results.append(("Cache Performance", "WARN", f"{time2:.1f}ms")) except Exception as e: print(f"FAIL: {e}") test_results.append(("Cache Performance", "FAIL", str(e))) # Test 7: Batch Generation Performance print("\nTest 7: Batch Generation Performance") print("-" * 30) try: test_components = ["alternator", "ecu", "pcm", "sensor", "relay"] start_time = time.time() for comp in test_components: bridge.generate_component_locally(comp) total_time = (time.time() - start_time) * 1000 avg_time = total_time / len(test_components) print(f"SUCCESS: Generated {len(test_components)} components") print(f" Total Time: {total_time:.1f}ms") print(f" Average: {avg_time:.1f}ms per component") print(f" Token Usage: 0") test_results.append(("Batch Generation", "PASS", f"{avg_time:.1f}ms avg")) except Exception as e: print(f"FAIL: {e}") test_results.append(("Batch Generation", "FAIL", str(e))) # Summary print("\n" + "=" * 60) print("TEST SUMMARY") print("=" * 60) for test_name, status, detail in test_results: status_icon = { "PASS": "SUCCESS", "FAIL": "FAIL", "SKIP": "SKIP", "WARN": "WARNING" }.get(status, status) print(f"{test_name:.<30} {status_icon:>10} ({detail})") # Overall result passed = sum(1 for _, status, _ in test_results if status == "PASS") failed = sum(1 for _, status, _ in test_results if status == "FAIL") skipped = sum(1 for _, status, _ in test_results if status == "SKIP") print("\n" + "-" * 60) print(f"Results: {passed} passed, {failed} failed, {skipped} skipped") if failed == 0: print("\nSUCCESS: All critical tests passed!") print("\nKey Achievements:") print(" - Zero token usage confirmed") print(" - Sub-second generation verified") print(" - Component discovery working") print(" - Cache optimization functional") return 0 else: print("\nWARNING: Some tests failed. Check output above.") return 1 if __name__ == "__main__": exit_code = asyncio.run(test_integration()) sys.exit(exit_code)

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/shdann/mcp-blend'

If you have feedback or need assistance with the MCP directory API, please join our Discord server