@@ -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