"""
測試功能列表樹狀結構 API
"""
import requests
import json

BASE_URL = "http://localhost:10181/api/v1"

def test_menu_tree():
    """測試取得選單樹狀結構"""

    print("=" * 80)
    print("測試 1: 系統管理公司 (is_sysmana=true)")
    print("=" * 80)

    response = requests.get(f"{BASE_URL}/system-functions/menu/tree?is_sysmana=true")

    if response.status_code == 200:
        tree = response.json()
        print(f"Status: {response.status_code} OK")
        print(f"Total root items: {len(tree)}")
        print("\nMenu Tree:")
        print(json.dumps(tree, indent=2, ensure_ascii=False))
    else:
        print(f"ERROR: {response.status_code}")
        print(response.text)

    print("\n" + "=" * 80)
    print("測試 2: 一般租戶 (is_sysmana=false)")
    print("=" * 80)

    response = requests.get(f"{BASE_URL}/system-functions/menu/tree?is_sysmana=false")

    if response.status_code == 200:
        tree = response.json()
        print(f"Status: {response.status_code} OK")
        print(f"Total root items: {len(tree)}")
        print("\nMenu Tree:")
        print(json.dumps(tree, indent=2, ensure_ascii=False))
    else:
        print(f"ERROR: {response.status_code}")
        print(response.text)

if __name__ == "__main__":
    test_menu_tree()
