ReMe/tests/unit/test_daily_index_dream.py
jinliyl 54fa3381d7
Some checks failed
CI and Release / Docker / Build and test / amd64 (push) Has been cancelled
CI and Release / Docker / Build and test / arm64 (push) Has been cancelled
Security / CodeQL / Analyze python (push) Has been cancelled
CI / Python quality / Pre-commit (push) Has been cancelled
CI / Python tests / Unit Tests - py3.12 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.13 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.14 (push) Has been cancelled
CI / Python packages / Build and verify distributions (push) Has been cancelled
CI / Python quality / GitHub Actions (push) Has been cancelled
CI / Python tests / Hermes embedded - ubuntu-latest (push) Has been cancelled
CI / Python tests / Hermes embedded - windows-latest (push) Has been cancelled
CI / Python tests / Unit Tests - py3.11 (push) Has been cancelled
CI / ReMe Studio / Studio checks (push) Has been cancelled
Deploy / Documentation / Build documentation (push) Has been cancelled
CI / Windows / CLI smoke - py3.11 (push) Has been cancelled
Security / CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI and Release / Docker / Publish multi-platform tags (push) Has been cancelled
Deploy / Documentation / deploy (push) Has been cancelled
refactor(core): reorganize the ReMe runtime and shared helpers (#769)
* refactor(core): reorganize the ReMe runtime and shared helpers

* test(status): import the base component from its canonical module

* test: remove redundant unit checks

* refactor(core): use canonical runtime imports and shared CLI discovery

Restore evolve behavior to the base branch and update its imports. Use Application as the runtime entry point and encode SSE in the HTTP service.

* fix(cli): honor caller config when service replay is incomplete

Use partial startup overrides for port probes and resolve named configs before requesting the service process working directory.
2026-11-20 22:06:46 +08:00

39 lines
1.7 KiB
Python

"""Regression tests for daily-index errors during dream extraction."""
from unittest.mock import AsyncMock, Mock, patch
import pytest
from reme.core.context import ApplicationContext, RuntimeContext
from reme.components.file_catalog import BaseFileCatalog
from reme.components.file_store import BaseFileStore
from reme.steps.evolve.dream.extract import DreamExtractStep
@pytest.mark.asyncio
async def test_dream_extract_reports_unreadable_index_without_mutating_source(tmp_path):
"""Index refresh failure must not be mistaken for successful extraction."""
note = tmp_path / "daily/2026-05-28/session.md"
note.parent.mkdir(parents=True)
note.write_text("source input", encoding="utf-8")
catalog = Mock(spec=BaseFileCatalog)
catalog.get_nodes = AsyncMock(return_value=[])
catalog.delete = AsyncMock()
store = Mock(spec=BaseFileStore)
store.workspace_path = tmp_path
step = DreamExtractStep(scan_days=1, app_context=ApplicationContext(workspace_dir=str(tmp_path)))
with (
patch(
"reme.steps.evolve.dream.extract.refresh_day_index",
new=AsyncMock(return_value={"error": "daily index is unreadable: malformed YAML"}),
),
patch("reme.steps.evolve.dream.extract.llm_available", return_value=False),
):
response = await step(RuntimeContext(date="2026-05-28", file_catalog=catalog, file_store=store))
assert response.success is False
assert "daily index refresh failed" in response.answer
assert "daily index is unreadable" in response.answer
assert any("daily index refresh failed" in error for error in response.metadata["dream"]["errors"])
assert note.read_text(encoding="utf-8") == "source input"