diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca264b7..8ccb15e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} - - run: pip install -r requirements.txt pytest + - run: pip install -e ".[dev]" - run: python -m pytest tests/ -v lint: diff --git a/tests/conftest.py b/tests/conftest.py index 757ca51..d0c30c2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -27,11 +27,11 @@ os.environ["HOMEDRIVE"] = os.path.splitdrive(_session_tmp)[0] or "C:" os.environ["HOMEPATH"] = os.path.splitdrive(_session_tmp)[1] or _session_tmp # Now it is safe to import mempalace modules that trigger initialisation. -import chromadb -import pytest +import chromadb # noqa: E402 +import pytest # noqa: E402 -from mempalace.config import MempalaceConfig -from mempalace.knowledge_graph import KnowledgeGraph +from mempalace.config import MempalaceConfig # noqa: E402 +from mempalace.knowledge_graph import KnowledgeGraph # noqa: E402 @pytest.fixture(scope="session", autouse=True) @@ -108,10 +108,38 @@ def seeded_collection(collection): "Evaluate ChromaDB alternatives for vector search.", ], metadatas=[ - {"wing": "project", "room": "backend", "source_file": "auth.py", "chunk_index": 0, "added_by": "miner", "filed_at": "2026-01-01T00:00:00"}, - {"wing": "project", "room": "backend", "source_file": "db.py", "chunk_index": 0, "added_by": "miner", "filed_at": "2026-01-02T00:00:00"}, - {"wing": "project", "room": "frontend", "source_file": "App.tsx", "chunk_index": 0, "added_by": "miner", "filed_at": "2026-01-03T00:00:00"}, - {"wing": "notes", "room": "planning", "source_file": "sprint.md", "chunk_index": 0, "added_by": "miner", "filed_at": "2026-01-04T00:00:00"}, + { + "wing": "project", + "room": "backend", + "source_file": "auth.py", + "chunk_index": 0, + "added_by": "miner", + "filed_at": "2026-01-01T00:00:00", + }, + { + "wing": "project", + "room": "backend", + "source_file": "db.py", + "chunk_index": 0, + "added_by": "miner", + "filed_at": "2026-01-02T00:00:00", + }, + { + "wing": "project", + "room": "frontend", + "source_file": "App.tsx", + "chunk_index": 0, + "added_by": "miner", + "filed_at": "2026-01-03T00:00:00", + }, + { + "wing": "notes", + "room": "planning", + "source_file": "sprint.md", + "chunk_index": 0, + "added_by": "miner", + "filed_at": "2026-01-04T00:00:00", + }, ], ) return collection diff --git a/tests/test_dialect.py b/tests/test_dialect.py index 9827b3c..2ef1df6 100644 --- a/tests/test_dialect.py +++ b/tests/test_dialect.py @@ -148,7 +148,9 @@ class TestZettelEncoding: class TestDecode: def test_decode_roundtrip(self): d = Dialect() - encoded = "001|ALC+BOB|2025-01-01|test_title\nARC:journey\n001:ALC|memory_ai|\"test quote\"|0.9|joy" + encoded = ( + '001|ALC+BOB|2025-01-01|test_title\nARC:journey\n001:ALC|memory_ai|"test quote"|0.9|joy' + ) decoded = d.decode(encoded) assert decoded["header"]["file"] == "001" assert decoded["arc"] == "journey" diff --git a/tests/test_knowledge_graph.py b/tests/test_knowledge_graph.py index 6c6cfa1..a8fcd9a 100644 --- a/tests/test_knowledge_graph.py +++ b/tests/test_knowledge_graph.py @@ -5,8 +5,6 @@ Covers: entity CRUD, triple CRUD, temporal queries, invalidation, timeline, stats, and edge cases (duplicate triples, ID collisions). """ -from mempalace.knowledge_graph import KnowledgeGraph - class TestEntityOperations: def test_add_entity(self, kg): diff --git a/tests/test_mcp_server.py b/tests/test_mcp_server.py index c6d8a3a..2ca177e 100644 --- a/tests/test_mcp_server.py +++ b/tests/test_mcp_server.py @@ -58,11 +58,13 @@ class TestHandleRequest: def test_unknown_tool(self): from mempalace.mcp_server import handle_request - resp = handle_request({ - "method": "tools/call", - "id": 3, - "params": {"name": "nonexistent_tool", "arguments": {}}, - }) + resp = handle_request( + { + "method": "tools/call", + "id": 3, + "params": {"name": "nonexistent_tool", "arguments": {}}, + } + ) assert resp["error"]["code"] == -32601 def test_unknown_method(self): @@ -78,11 +80,13 @@ class TestHandleRequest: # Create a collection so status works _get_collection(palace_path, create=True) - resp = handle_request({ - "method": "tools/call", - "id": 5, - "params": {"name": "mempalace_status", "arguments": {}}, - }) + resp = handle_request( + { + "method": "tools/call", + "id": 5, + "params": {"name": "mempalace_status", "arguments": {}}, + } + ) assert "result" in resp content = json.loads(resp["result"]["content"][0]["text"]) assert "total_drawers" in content diff --git a/tests/test_searcher.py b/tests/test_searcher.py index 6750162..44a05aa 100644 --- a/tests/test_searcher.py +++ b/tests/test_searcher.py @@ -24,10 +24,7 @@ class TestSearchMemories: def test_wing_and_room_filter(self, palace_path, seeded_collection): result = search_memories("code", palace_path, wing="project", room="frontend") - assert all( - r["wing"] == "project" and r["room"] == "frontend" - for r in result["results"] - ) + assert all(r["wing"] == "project" and r["room"] == "frontend" for r in result["results"]) def test_n_results_limit(self, palace_path, seeded_collection): result = search_memories("code", palace_path, n_results=2)