Files
unitforge/test_templates.py
William Valentin 860f60591c Fix contrast issues with text-muted and bg-dark classes
- Fixed Bootstrap bg-dark class to use better contrasting color
- Added comprehensive text-muted contrast fixes for various contexts
- Improved dark theme colors for better accessibility
- Fixed CSS inheritance issues for code elements in dark contexts
- All color choices meet WCAG AA contrast requirements
2025-09-14 14:58:35 -07:00

58 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""
Test script to output template data as JSON for debugging the templates page.
"""
import json
import sys
from pathlib import Path
# Add backend to path
sys.path.insert(0, str(Path(__file__).parent / "backend"))
try:
from app.core.templates import template_registry
def template_to_dict(template):
"""Convert UnitTemplate to dictionary."""
parameters = []
for param in template.parameters:
param_dict = {
"name": param.name,
"description": param.description,
"type": param.parameter_type,
"required": param.required,
"default": param.default,
"choices": param.choices,
"example": param.example,
}
parameters.append(param_dict)
return {
"name": template.name,
"description": template.description,
"unit_type": template.unit_type.value,
"category": template.category,
"parameters": parameters,
"tags": template.tags or [],
}
# Get all templates
templates = template_registry.list_templates()
template_data = [template_to_dict(template) for template in templates]
print("Available templates:")
print(json.dumps(template_data, indent=2))
print(f"\nTotal templates: {len(template_data)}")
# Show categories
categories = set(t["category"] for t in template_data)
print(f"Categories: {sorted(categories)}")
except Exception as e:
print(f"Error: {e}")
import traceback
traceback.print_exc()