28 lines
952 B
Python
28 lines
952 B
Python
"""测试 PostgreSQL 连接"""
|
|
import httpx
|
|
|
|
# 测试登录
|
|
resp = httpx.post('http://localhost:8000/api/v1/auth/login',
|
|
data={'username': 'admin', 'password': 'admin123'})
|
|
print(f'登录: {resp.status_code}')
|
|
token = resp.json().get('access_token', '')[:50]
|
|
print(f'Token: {token}...')
|
|
|
|
token = resp.json().get('access_token')
|
|
headers = {'Authorization': f'Bearer {token}'}
|
|
|
|
# 测试科室
|
|
resp = httpx.get('http://localhost:8000/api/v1/departments', headers=headers)
|
|
data = resp.json().get('data', [])
|
|
print(f'科室: {resp.status_code} - {len(data)} 条')
|
|
|
|
# 测试员工
|
|
resp = httpx.get('http://localhost:8000/api/v1/staff', headers=headers)
|
|
data = resp.json().get('data', [])
|
|
print(f'员工: {resp.status_code} - {len(data)} 条')
|
|
|
|
# 测试指标
|
|
resp = httpx.get('http://localhost:8000/api/v1/indicators', headers=headers)
|
|
data = resp.json().get('data', [])
|
|
print(f'指标: {resp.status_code} - {len(data)} 条')
|