issue-14 #34
|
|
@ -76,3 +76,36 @@ async def test_admin_endpoint_authorized_for_admin(
|
|||
data = response.json()
|
||||
assert len(data) == 1
|
||||
assert data[0]["email"] == "superadmin@acupedia.test"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_admin_modules_returns_generic_categories(
|
||||
async_client: AsyncClient,
|
||||
sample_admin: AppUser,
|
||||
mock_admin_service: MagicMock,
|
||||
) -> None:
|
||||
mock_modules = [
|
||||
{"id": str(uuid4()), "code": "m0001", "slug": "acupuncture-points", "name": "Acupuncture Points", "category": "Points", "color": "#2563EB", "icon": "water-outline"},
|
||||
{"id": str(uuid4()), "code": "m0011", "slug": "eight-principles", "name": "Eight Principles", "category": "Patterns", "color": "#8B5CF6", "icon": "analytics-outline"},
|
||||
{"id": str(uuid4()), "code": "m0031", "slug": "nutrition", "name": "Nutrition", "category": "Nutrition", "color": "#10B981", "icon": "leaf-outline"},
|
||||
{"id": str(uuid4()), "code": "m0041", "slug": "auriculotherapy", "name": "Auriculotherapy", "category": "Therapeutics", "color": "#EC4899", "icon": "medkit-outline"},
|
||||
]
|
||||
mock_admin_service.list_modules = AsyncMock(return_value=mock_modules)
|
||||
app.dependency_overrides[get_current_admin] = lambda: sample_admin
|
||||
app.dependency_overrides[get_admin_service] = lambda: mock_admin_service
|
||||
|
||||
response = await async_client.get(
|
||||
"/api/admin/modules",
|
||||
headers={"Authorization": "Bearer admin_token"},
|
||||
)
|
||||
app.dependency_overrides.pop(get_current_admin, None)
|
||||
app.dependency_overrides.pop(get_admin_service, None)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert len(data) == 4
|
||||
categories = {m["code"]: m["category"] for m in data}
|
||||
assert categories["m0001"] == "Points"
|
||||
assert categories["m0011"] == "Patterns"
|
||||
assert categories["m0031"] == "Nutrition"
|
||||
assert categories["m0041"] == "Therapeutics"
|
||||
|
|
|
|||
Loading…
Reference in New Issue