mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-30 01:52:29 +00:00
* refactor(steps): update naming conventions in components and configuration Updated naming conventions across multiple files, changing colon-separated names to underscore-separated format, and added new step definitions along with documentation updates. Key changes: - Replaced `Synchronizer` with `AutoMemory` as the counterpart component for cold-write operations - Updated naming conventions in all related configuration files (e.g., `frontmatter:read` → `frontmatter_read`) - Added new step definitions such as `submit_slug_updates` and `auto_memory` - Updated relevant documentation - Modified log output format for improved readability * refactor(evolve): Refactor the auto-memory module and update related configurations - Remove the old slug update commit step file - Add new auto-memory planner and writer steps - Update __init__.py to export the new step classes - Modify the auto_memory configuration structure in default.yaml - Update the slug field description for clearer explanation of its purpose * up * up * refactor(tests): Move unit test directory from `tests4/unittest` to `tests4/unit` Additionally, the assertion logic in test files has been updated: direct comparisons of `payload["notes"]` have been replaced with checks verifying the presence of paths and metadata within the response content. Furthermore, some test expectations have been simplified—for example, using `count` instead of asserting against specific note lists. Specific changes include: - Updating workflow configurations to align with the new test directory structure - Modifying assertions across multiple test methods to make them more flexible and maintainable - Cleaning up and optimizing parts of the test code structure This is a comprehensive test refactoring effort aimed at improving test readability and robustness. * Refactor(steps): Update memory writing logic and optimize JSON schema structure Improved the write strategy description in `auto_memory_writer.yaml` to emphasize using `edit` over `write`. Adjusted the `json_schema` structure in `base_step.py` to support the new function definition format. Also corrected grammatical issues in the related documentation. * Fix: Improve frontend data parsing error handling and update test files Added capture and handling logic for YAML parsing exceptions, providing more detailed error messages when frontend data format issues occur. Also corrected the description text in a test file.
68 lines
2.6 KiB
Python
68 lines
2.6 KiB
Python
"""
|
|
Tests for the default watch path construction in ``ReMeLight``.
|
|
|
|
Verifies that the built-in watch list picks a single ``MEMORY.md`` /
|
|
``memory.md`` spelling so the file is not indexed twice on case-insensitive
|
|
filesystems (Windows NTFS, macOS APFS/HFS+). See agentscope-ai/ReMe#228.
|
|
"""
|
|
|
|
# pylint: disable=redefined-outer-name,protected-access,missing-function-docstring,missing-class-docstring
|
|
# pylint: disable=no-name-in-module
|
|
|
|
import tempfile
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from reme.reme_light import ReMeLight
|
|
|
|
|
|
@pytest.fixture
|
|
def temp_working_dir():
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
yield tmp
|
|
|
|
|
|
def _captured_watch_paths(working_dir: str, *, default_file_watcher_config=None):
|
|
"""Capture the ``watch_paths`` that ``ReMeLight`` would forward to its
|
|
parent ``Application.__init__``, without spinning up the full app stack."""
|
|
captured: dict = {}
|
|
|
|
def _capture(*_args, **kwargs):
|
|
captured.update(kwargs)
|
|
|
|
with patch("reme.reme_light.Application.__init__", _capture):
|
|
ReMeLight(
|
|
working_dir=working_dir,
|
|
default_file_watcher_config=default_file_watcher_config,
|
|
)
|
|
|
|
return list((captured.get("default_file_watcher_config") or {}).get("watch_paths", []))
|
|
|
|
|
|
class TestDefaultWatchPaths:
|
|
def test_defaults_to_uppercase_memory_md_when_neither_exists(self, temp_working_dir):
|
|
paths = _captured_watch_paths(temp_working_dir)
|
|
memory_dir = str(Path(temp_working_dir).absolute() / "memory")
|
|
assert paths == [str(Path(temp_working_dir).absolute() / "MEMORY.md"), memory_dir]
|
|
|
|
def test_picks_lowercase_memory_md_when_only_it_exists(self, temp_working_dir):
|
|
(Path(temp_working_dir) / "memory.md").write_text("")
|
|
if (Path(temp_working_dir) / "MEMORY.md").exists():
|
|
pytest.skip("case-insensitive filesystem treats both spellings as one file")
|
|
paths = _captured_watch_paths(temp_working_dir)
|
|
assert paths[0] == str(Path(temp_working_dir).absolute() / "memory.md")
|
|
|
|
def test_prefers_uppercase_memory_md_when_it_exists(self, temp_working_dir):
|
|
(Path(temp_working_dir) / "MEMORY.md").write_text("")
|
|
paths = _captured_watch_paths(temp_working_dir)
|
|
assert paths[0] == str(Path(temp_working_dir).absolute() / "MEMORY.md")
|
|
|
|
def test_user_provided_watch_paths_pass_through(self, temp_working_dir):
|
|
custom = [str(Path(temp_working_dir) / "notes.md")]
|
|
paths = _captured_watch_paths(
|
|
temp_working_dir,
|
|
default_file_watcher_config={"watch_paths": custom},
|
|
)
|
|
assert paths == custom
|