File size: 801 Bytes
f440f03
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Tests attēlu ģenerēšanai."""

from unittest.mock import AsyncMock, patch

import pytest
from fastapi import HTTPException

from maris_core.images.generate_image import ImageRequest, generate_image


@pytest.mark.asyncio
async def test_generate_image_requires_explicit_maris_model() -> None:
    """Pārbauda, ka attēlu ģenerēšana neatgriež placeholder fallback."""
    with (
        patch(
            "maris_core.utils.hf_integration.HFIntegration.save_generation",
            new_callable=AsyncMock,
        ),
        patch.dict("os.environ", {"IMAGE_MODEL": ""}, clear=False),
    ):
        req = ImageRequest(prompt="zaļš mežs ar upi")
        with pytest.raises(HTTPException) as exc_info:
            await generate_image(req)
        assert exc_info.value.status_code == 503