mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-19 00:01:33 +00:00
Some checks failed
Security / CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI / Documentation / Test and build documentation (push) Has been cancelled
CI / Python packages / Build and verify distributions (push) Has been cancelled
CI / Python quality / Pre-commit (push) Has been cancelled
CI / Python tests / Unit Tests - py3.11 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.13 (push) Has been cancelled
CI / ReMe Studio / Studio checks (push) Has been cancelled
CI / Windows / CLI smoke - py3.11 (push) Has been cancelled
Deploy / Documentation / Build documentation (push) Has been cancelled
Security / CodeQL / Analyze python (push) Has been cancelled
CI / Python tests / Unit Tests - py3.12 (push) Has been cancelled
Deploy / Documentation / deploy (push) Has been cancelled
* Add optional tag generation and normalization to auto memory * Add tag index components and clean up temporary JSONL files * Preserve tag index state when reconciliation fails * Refactor and streamline application implementation * Fix pylint C1803 warnings in tag normalization tests * Document optional tag index configuration * Make tag index failures non-blocking and disable auto-memory tags * fix(tag-index): fail closed and support reindexing * fix(tag-index): preserve complete query expressions --------- Co-authored-by: jinli.yl <jinli.yl@alibaba-inc.com>
51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
"""Tests for explicit scoped index rebuilds."""
|
|
|
|
from unittest.mock import AsyncMock
|
|
|
|
import pytest
|
|
|
|
from reme.components.file_store import LocalFileStore
|
|
from reme.components.runtime_context import RuntimeContext
|
|
from reme.config import resolve_app_config
|
|
from reme.steps.index import ReindexStep
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.parametrize("scope", ["bm25", "embedding", "tag"])
|
|
async def test_reindex_step_delegates_scope(scope):
|
|
"""The step forwards each individual scope without clearing the store."""
|
|
store = LocalFileStore(name=f"test_reindex_{scope}", embedding_store="")
|
|
store.reindex = AsyncMock(return_value={"indexed": 3, "scope": scope})
|
|
store.clear = AsyncMock()
|
|
|
|
response = await ReindexStep(file_store=store)(RuntimeContext(scope=scope))
|
|
|
|
store.reindex.assert_awaited_once_with(scope)
|
|
store.clear.assert_not_called()
|
|
assert response.metadata == {"indexed": 3, "scope": scope}
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_reindex_step_delegates_all_once():
|
|
"""The step delegates the composite scope exactly once."""
|
|
store = LocalFileStore(name="test_reindex_all", embedding_store="")
|
|
details = {
|
|
"scope": "all",
|
|
"bm25": {"scope": "bm25", "indexed": 3},
|
|
"embedding": {"scope": "embedding", "indexed": 3},
|
|
"tag": {"scope": "tag", "indexed": 3},
|
|
}
|
|
store.reindex = AsyncMock(return_value=details)
|
|
|
|
response = await ReindexStep(file_store=store)(RuntimeContext(scope="all"))
|
|
|
|
store.reindex.assert_awaited_once_with("all")
|
|
assert response.metadata == details
|
|
|
|
|
|
def test_reindex_job_schema_exposes_tag_scope():
|
|
"""The public job contract accepts every scope implemented by the file store."""
|
|
config = resolve_app_config(config="default", log_config=False)
|
|
scope = config["jobs"]["reindex"]["parameters"]["properties"]["scope"]
|
|
|
|
assert scope["enum"] == ["all", "bm25", "embedding", "tag"]
|