fix: CI failures — update workflow for uv migration, fix lint and format
- Switch CI install step from `pip install -r requirements.txt` to `pip install -e ".[dev]"` since requirements.txt was removed - Add noqa: E402 to intentionally-late imports in conftest.py (HOME must be isolated before mempalace imports) - Remove unused KnowledgeGraph import in test_knowledge_graph.py - Apply ruff formatting to test files
This commit is contained in:
@@ -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:
|
||||
|
||||
+36
-8
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -58,11 +58,13 @@ class TestHandleRequest:
|
||||
def test_unknown_tool(self):
|
||||
from mempalace.mcp_server import handle_request
|
||||
|
||||
resp = handle_request({
|
||||
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({
|
||||
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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user