Files
invoke-ai--invokeai/tests/app/routers/test_session_queue_image_move_maintenance.py
wehub-resource-sync cddb07a176
docs / deploy (push) Has been cancelled
docs / changes (push) Has been cancelled
docs / check-and-build (push) Has been cancelled
build container image / cpu (push) Has been cancelled
build container image / cuda (push) Has been cancelled
build container image / rocm (push) Has been cancelled
frontend checks / frontend-checks (push) Has been cancelled
frontend tests / frontend-tests (push) Has been cancelled
lfs checks / lfs-check (push) Has been cancelled
python checks / python-checks (push) Has been cancelled
python tests / py3.12: macos-default (push) Has been cancelled
python tests / py3.11: windows-cpu (push) Has been cancelled
python tests / py3.12: windows-cpu (push) Has been cancelled
python tests / py3.11: linux-cpu (push) Has been cancelled
typegen checks / typegen-checks (push) Has been cancelled
uv lock checks / uv-lock-checks (push) Has been cancelled
openapi checks / openapi-checks (push) Has been cancelled
python tests / py3.11: macos-default (push) Has been cancelled
python tests / py3.12: linux-cpu (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:22:06 +08:00

41 lines
1.3 KiB
Python

from unittest.mock import MagicMock
import pytest
from fastapi import HTTPException
from invokeai.app.api.dependencies import ApiDependencies
from invokeai.app.api.routers.session_queue import enqueue_batch
from invokeai.app.services.session_queue.session_queue_common import DEFAULT_QUEUE_ID, Batch
from invokeai.app.services.shared.graph import Graph
class MockApiDependencies(ApiDependencies):
def __init__(self, invoker) -> None:
self.invoker = invoker
@pytest.fixture
def anyio_backend() -> str:
return "asyncio"
@pytest.mark.anyio
async def test_enqueue_batch_is_blocked_during_image_move_maintenance(
monkeypatch: pytest.MonkeyPatch, mock_invoker
) -> None:
mock_deps = MockApiDependencies(mock_invoker)
mock_invoker.services.image_moves = MagicMock()
mock_invoker.services.image_moves.is_maintenance_active.return_value = True
monkeypatch.setattr("invokeai.app.api.routers.image_move_maintenance.ApiDependencies", mock_deps)
with pytest.raises(HTTPException) as exc:
await enqueue_batch(
current_user=MagicMock(user_id="user-id"),
queue_id=DEFAULT_QUEUE_ID,
batch=Batch(graph=Graph()),
prepend=False,
)
assert exc.value.status_code == 409
assert exc.value.detail == "Image storage maintenance is active"