Skip to content

Commit ad58d8a

Browse files
jope-bmclaude
andcommitted
test: Add comprehensive tests for v2 API endpoints
Add complete test coverage for all v2 API endpoints using integer IDs: Knowledge router tests (14 tests): - Resolve identifier by permalink - Get entity by ID - Create entity with observations/relations - Update entity by ID (PUT) - Edit entity (PATCH with append/find_replace) - Delete entity by ID - Move entity (ID stability) - Error handling (404s) - V2-specific features (api_version field) Project router tests (14 tests): - Get project by ID - Update project (path, active status) - Set default project by ID - Delete project by ID - Delete with delete_notes parameter - Error handling (404s, validation) - ID stability after operations All tests properly use entity_repository to look up entity IDs after creation, as EntityResponse doesn't expose ID field. Project tests use project_service.add_project() to ensure projects exist in both database and configuration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9207052 commit ad58d8a

3 files changed

Lines changed: 658 additions & 0 deletions

File tree

tests/api/v2/conftest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Fixtures for V2 API tests."""
2+
3+
import pytest
4+
5+
from basic_memory.models import Project
6+
7+
8+
@pytest.fixture
9+
def v2_project_url(test_project: Project) -> str:
10+
"""Create a URL prefix for v2 project-scoped routes using project ID.
11+
12+
This helps tests generate the correct URL for v2 project-scoped routes
13+
which use integer project IDs instead of permalinks.
14+
"""
15+
return f"/v2/{test_project.id}"
16+
17+
18+
@pytest.fixture
19+
def v2_projects_url() -> str:
20+
"""Base URL for v2 project management endpoints."""
21+
return "/v2/projects"

0 commit comments

Comments
 (0)