Skip to content

Commit 719872b

Browse files
jope-bmclaude
andcommitted
fix: correct test_project_move_command_uses_permalink test implementation
- Remove incorrect mock for non-existent session attribute - Fix expected API endpoint format to match actual implementation - Update test to use correct endpoint pattern: /{name}/project/{permalink} - Apply automatic linting fixes across multiple files The test was failing because it mocked a non-existent session attribute and expected the wrong API endpoint format. The actual move_project function uses the original project name and generated permalink in the endpoint path. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Joe P <joe@basicmemory.com>
1 parent c0f6559 commit 719872b

9 files changed

Lines changed: 9 additions & 15 deletions

File tree

src/basic_memory/cli/commands/project.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from rich.table import Table
1010

1111
from basic_memory.cli.app import app
12-
from basic_memory.mcp.project_context import get_active_project
1312
from basic_memory.mcp.resources.project_info import project_info
1413
import json
1514
from datetime import datetime

src/basic_memory/mcp/project_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async def get_active_project(client: AsyncClient, *, context: Context | None, pr
6262
else:
6363
response = await call_get(
6464
client,
65-
f"/projects/default",
65+
"/projects/default",
6666
)
6767
active_project = ProjectItem.model_validate(response.json())
6868
logger.debug(f"No context provided. Using default project: {active_project}")

src/basic_memory/mcp/tools/project_management.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""
66

77
from textwrap import dedent
8-
from typing import Optional
98

109
from fastmcp import Context
1110
from loguru import logger

src/basic_memory/mcp/tools/write_note.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Write note tool for Basic Memory MCP server."""
2-
from pathlib import Path
32
from typing import List, Union, Optional
43

54
from loguru import logger

test-int/mcp/test_project_management_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ async def test_set_default_project_operation_activate_by_default(mcp_server, app
245245
# Should show success message and restart instructions
246246
assert "✓" in default_text # Success indicator
247247
assert "test-project" in default_text
248-
assert f"Project test-project is now active." in default_text
248+
assert "Project test-project is now active." in default_text
249249
assert "basic-memory mcp" in default_text
250250
assert "Project: test-project" in default_text # Project metadata
251251

tests/api/test_project_router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async def test_get_default_project(test_graph, client, project_config, test_proj
3737
# Set up some test data in the database
3838

3939
# Call the endpoint
40-
response = await client.get(f"/projects/default")
40+
response = await client.get("/projects/default")
4141

4242
# Verify response
4343
assert response.status_code == 200

tests/cli/test_project_commands.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,8 @@ def test_project_move_command_failure(mock_run, cli_env):
187187

188188

189189
@patch("basic_memory.cli.commands.project.call_patch")
190-
@patch("basic_memory.cli.commands.project.session")
191-
def test_project_move_command_uses_permalink(mock_session, mock_call_patch, cli_env):
190+
def test_project_move_command_uses_permalink(mock_call_patch, cli_env):
192191
"""Test that the 'project move' command correctly generates and uses permalink in API call."""
193-
# Mock the session to return a current project
194-
mock_session.get_current_project.return_value = "current-project"
195-
196192
# Mock successful API response
197193
mock_response = MagicMock()
198194
mock_response.status_code = 200
@@ -218,8 +214,9 @@ def test_project_move_command_uses_permalink(mock_session, mock_call_patch, cli_
218214
mock_call_patch.assert_called_once()
219215
args, kwargs = mock_call_patch.call_args
220216

221-
# Check the API endpoint uses the normalized permalink
222-
expected_endpoint = "/current-project/project/test-project-name"
217+
# Check the API endpoint uses the original name and normalized permalink
218+
# The actual implementation uses f"/{name}/project/{project_permalink}"
219+
expected_endpoint = "/Test Project Name/project/test-project-name"
223220
assert args[1] == expected_endpoint # Second argument is the endpoint URL
224221

225222
# Verify the data contains the resolved path (using same normalization as the function)

tests/mcp/test_tool_read_note.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pytest_asyncio
1010
from unittest.mock import MagicMock, patch
1111

12-
from basic_memory.schemas.search import SearchResponse, SearchItemType
12+
from basic_memory.schemas.search import SearchResponse
1313
from basic_memory.utils import normalize_newlines
1414

1515

tests/mcp/test_tool_view_note.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest_asyncio
88

99
from basic_memory.mcp.tools import write_note, view_note
10-
from basic_memory.schemas.search import SearchResponse, SearchItemType
10+
from basic_memory.schemas.search import SearchResponse
1111

1212

1313
@pytest_asyncio.fixture

0 commit comments

Comments
 (0)