- Migrated from HIVE branding to WHOOSH across all components - Enhanced backend API with new services: AI models, BZZZ integration, templates, members - Added comprehensive testing suite with security, performance, and integration tests - Improved frontend with new components for project setup, AI models, and team management - Updated MCP server implementation with WHOOSH-specific tools and resources - Enhanced deployment configurations with production-ready Docker setups - Added comprehensive documentation and setup guides - Implemented age encryption service and UCXL integration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
121 lines
4.2 KiB
Python
121 lines
4.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Standalone test script for template system without database dependencies.
|
|
"""
|
|
import sys
|
|
import os
|
|
|
|
# Add the app directory to the path
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'app'))
|
|
|
|
from services.template_service import ProjectTemplateService
|
|
|
|
def test_template_service():
|
|
"""Test the template service functionality"""
|
|
print("🧪 Testing ProjectTemplateService...")
|
|
|
|
try:
|
|
# Initialize service
|
|
service = ProjectTemplateService()
|
|
print("✅ Service initialized successfully")
|
|
|
|
# List templates
|
|
templates = service.list_templates()
|
|
print(f"✅ Found {len(templates)} templates:")
|
|
|
|
for template in templates:
|
|
print(f" - {template['name']} ({template['template_id']})")
|
|
print(f" Category: {template['category']}")
|
|
print(f" Difficulty: {template['difficulty']}")
|
|
print(f" Features: {len(template['features'])}")
|
|
print()
|
|
|
|
# Test getting specific template
|
|
if templates:
|
|
template_id = templates[0]['template_id']
|
|
template_details = service.get_template(template_id)
|
|
|
|
if template_details:
|
|
print(f"✅ Retrieved template details for '{template_id}':")
|
|
print(f" - Metadata keys: {list(template_details['metadata'].keys())}")
|
|
print(f" - Files: {len(template_details['starter_files'])}")
|
|
|
|
# List some starter files
|
|
files = list(template_details['starter_files'].keys())[:5]
|
|
print(f" - Sample files: {files}")
|
|
|
|
if len(template_details['starter_files']) > 5:
|
|
print(f" ... and {len(template_details['starter_files']) - 5} more")
|
|
else:
|
|
print(f"❌ Failed to retrieve template details for '{template_id}'")
|
|
|
|
print("\n🎉 Template service test completed successfully!")
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"❌ Template service test failed: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
def test_template_creation():
|
|
"""Test creating a project from template"""
|
|
print("\n🧪 Testing project creation from template...")
|
|
|
|
try:
|
|
service = ProjectTemplateService()
|
|
templates = service.list_templates()
|
|
|
|
if not templates:
|
|
print("⚠️ No templates available for testing")
|
|
return True
|
|
|
|
template_id = templates[0]['template_id']
|
|
project_data = {
|
|
'name': 'test-project',
|
|
'description': 'A test project from template',
|
|
'author': 'Test User'
|
|
}
|
|
|
|
# Create a temporary directory for testing
|
|
import tempfile
|
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
result = service.create_project_from_template(template_id, project_data, temp_dir)
|
|
|
|
print(f"✅ Project created from template '{template_id}':")
|
|
print(f" - Files created: {len(result['files_created'])}")
|
|
print(f" - Template ID: {result['template_id']}")
|
|
print(f" - Project path: {result['project_path']}")
|
|
|
|
# Verify some files were created
|
|
import os
|
|
files_exist = 0
|
|
for filename in result['files_created'][:3]:
|
|
file_path = os.path.join(temp_dir, filename)
|
|
if os.path.exists(file_path):
|
|
files_exist += 1
|
|
|
|
print(f" - Verified {files_exist} files exist")
|
|
|
|
print("✅ Project creation test completed successfully!")
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"❌ Project creation test failed: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
print("🚀 Starting template system tests...\n")
|
|
|
|
success = True
|
|
success &= test_template_service()
|
|
success &= test_template_creation()
|
|
|
|
if success:
|
|
print("\n🎉 All tests passed!")
|
|
sys.exit(0)
|
|
else:
|
|
print("\n❌ Some tests failed!")
|
|
sys.exit(1) |