from __future__ import annotations

import json

import azure.functions as func

from app.functions.ai import chat


def test_chat_rejects_missing_prompt() -> None:
    request = func.HttpRequest(
        method="POST",
        url="http://localhost/api/chat",
        params={},
        body=json.dumps({"prompt": ""}).encode(),
        headers={"Content-Type": "application/json"},
    )

    import asyncio

    response = asyncio.run(chat(request))

    assert response.status_code == 400
