Files
EverOS/tests/unit/test_service/test_memorize_factories.py
Elliot Chen 518b8eca85 chore: initialize EverOS 1.0.0
md-first memory extraction framework for AI agents.

Markdown is the single source of truth; SQLite holds state and LanceDB
provides the rebuildable vector + BM25 + scalar index. The codebase follows
a single-direction DDD layering (entrypoints -> service -> memory -> infra,
with component / core / config cross-cutting) enforced by import-linter.

Engineering surface:
- Coding conventions in .claude/rules/ (path-scoped) and workflows in
  .claude/skills/ (/commit, /new-branch, /pr).
- GitHub Actions CI runs make lint + test + integration; pre-commit mirrors
  the gates locally (ruff, hygiene hooks, gitlint commit-msg).
- Commit messages follow Conventional Commits, enforced by gitlint.
- make lint also enforces datetime two-zone discipline and OpenAPI drift.
2026-06-06 07:33:17 +08:00

46 lines
1.5 KiB
Python

from __future__ import annotations
import importlib
from pathlib import Path
import pytest
from everos.infra.ome.engine import OfflineEngine
# everos.service.__init__ re-exports `memorize` as a function attribute on
# the package, which shadows the submodule when using `import ... as svc`.
# importlib.import_module bypasses that shadowing and returns the real module.
_svc = importlib.import_module("everos.service.memorize")
async def test_get_engine_returns_singleton(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
from everos.core.persistence import MemoryRoot
monkeypatch.setattr(
MemoryRoot, "default", classmethod(lambda cls: MemoryRoot(root=tmp_path))
)
monkeypatch.setattr(_svc, "_ome_engine", None, raising=False)
engine1 = _svc._get_engine()
engine2 = _svc._get_engine()
assert isinstance(engine1, OfflineEngine)
assert engine1 is engine2
async def test_get_user_pipeline_injects_engine(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
from everos.core.persistence import MemoryRoot
monkeypatch.setattr(
MemoryRoot, "default", classmethod(lambda cls: MemoryRoot(root=tmp_path))
)
monkeypatch.setattr(_svc, "_ome_engine", None, raising=False)
monkeypatch.setattr(_svc, "_user_pipeline", None, raising=False)
monkeypatch.setattr(_svc, "get_llm_client", lambda: object())
pipeline = _svc._get_user_pipeline()
assert pipeline._engine is _svc._get_engine()