Skip to content

Commit 59a1994

Browse files
committed
fix: fix bug that claude added for no reason
Signed-off-by: Joe P <joe@basicmemory.com>
1 parent 7e625fa commit 59a1994

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

src/basic_memory/cli/commands/project.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ def move_project(
160160
try:
161161
data = {"path": resolved_path}
162162

163+
project_permalink = generate_permalink(name)
163164
current_project = session.get_current_project()
164165
response = asyncio.run(
165-
call_patch(client, f"/{current_project}/project/{name}", json=data)
166+
call_patch(client, f"/{current_project}/project/{project_permalink}", json=data)
166167
)
167168
result = ProjectStatusResponse.model_validate(response.json())
168169

tests/cli/test_project_commands.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,44 @@ def test_project_move_command_failure(mock_run, cli_env):
184184
# Should exit with code 1 and show error message
185185
assert result.exit_code == 1
186186
assert "Error moving project" in result.output
187+
188+
189+
@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):
192+
"""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+
196+
# Mock successful API response
197+
mock_response = MagicMock()
198+
mock_response.status_code = 200
199+
mock_response.json.return_value = {
200+
"message": "Project 'Test Project Name' updated successfully",
201+
"status": "success",
202+
"default": False,
203+
}
204+
mock_call_patch.return_value = mock_response
205+
206+
runner = CliRunner()
207+
208+
# Test with a project name that needs normalization (spaces, mixed case)
209+
project_name = "Test Project Name"
210+
new_path = "/new/path/to/project"
211+
212+
result = runner.invoke(cli_app, ["project", "move", project_name, new_path])
213+
214+
# Verify command executed successfully
215+
assert result.exit_code == 0
216+
217+
# Verify call_patch was called with the correct permalink-formatted project name
218+
mock_call_patch.assert_called_once()
219+
args, kwargs = mock_call_patch.call_args
220+
221+
# Check the API endpoint uses the normalized permalink
222+
expected_endpoint = "/current-project/project/test-project-name"
223+
assert args[1] == expected_endpoint # Second argument is the endpoint URL
224+
225+
# Verify the data contains the resolved path
226+
expected_data = {"path": os.path.abspath(os.path.expanduser(new_path))}
227+
assert kwargs["json"] == expected_data

0 commit comments

Comments
 (0)