#!/usr/bin/env python
"""Direct test of service departments with unit_level"""
import sys
import os

# Add project root to path
project_root = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, project_root)

# Load .env
from lawrisk.utils.env_loader import load_env
load_env('.env', override=False)

# Import function directly
from lawrisk.services.licensing_repo import list_service_departments

print("=" * 60)
print("Service Departments List (with unit_level)")
print("=" * 60)
print()

departments = list_service_departments()

print(f"Total departments: {len(departments)}")
print()

for i, dept in enumerate(departments, 1):
    print(f"{i}. {dept['name']}")
    print(f"   Code: {dept['code']}")
    print(f"   Unit Level: {dept.get('unit_level', 'N/A')}")
    print(f"   Grade: {dept.get('grade', 'N/A')}")
    print(f"   Parent ID: {dept.get('parent_id', 'N/A')}")
    print(f"   Region ID: {dept.get('region_id', 'N/A')}")
    print()

print("=" * 60)
