"""Quick test for rule engine."""
import sys
sys.path.insert(0, ".")
from app.services.rule_engine import (
    get_parameter_registry, recommend_range, generate_plan,
    BoundaryConditions, generate_values,
)

reg = get_parameter_registry()
print(f"Parameters registered: {len(reg)}")
for p in reg:
    print(f"  {p['name']} ({p['category']}): {p['default_start']}-{p['default_stop']} {p['unit']}")

print()
bc = BoundaryConditions.from_dict({
    "outer_diameter_mm": 76,
    "inner_diameter_mm": 40,
    "speed_rpm": 5000,
    "current_a": 21,
    "magnet_temp_c": 100,
})
r = recommend_range("Airgap", bc)
print(f"Airgap range: {r}")

r2 = recommend_range("Magnet_Length", bc)
print(f"Magnet_Length range: {r2}")

r3 = recommend_range("RMSCurrent", bc)
print(f"RMSCurrent range: {r3}")

print()
plan = generate_plan(bc, model_path="test.mot")
print(f"Generated plan: {plan['name']}")
print(f"  topology: {plan['topology']}")
print(f"  estimated_points: {plan['estimated_points']}")
print(f"  estimated_time_min: {plan['estimated_time_min']}")
for v in plan["variables"]:
    print(f"  {v['name']}: start={v['start']}, stop={v['stop']}, step={v['step']}")
    print(f"    values={v['values']}")
    print(f"    notes={v['recommendation_notes']}")

print()
vals = generate_values(0.6, 1.5, 0.3)
print(f"generate_values(0.6, 1.5, 0.3) = {vals}")

print("\n=== RULE ENGINE TESTS PASSED ===")
