mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
fix: Update CloudProjectCreateResponse schema to match API response
The /proxy/projects/projects POST endpoint returns a ProjectStatusResponse with fields: message, status, default, old_project, new_project. Updated CloudProjectCreateResponse schema to match this format instead of expecting name, path, message fields. Also updated all related tests to use the correct response format: - tests/cli/test_cloud_utils.py (3 tests) - tests/cli/test_bisync_commands.py (1 test) Fixes the validation error when creating cloud projects via upload command: "bm cloud upload --project test --create-project specs" Signed-off-by: Pablo Hernandez <pablo@basicmachines.co> Signed-off-by: phernandez <paul@basicmachines.co>
This commit is contained in:
@@ -87,7 +87,6 @@ async def get_client() -> AsyncIterator[AsyncClient]:
|
||||
# Auth header set ONCE at client creation
|
||||
proxy_base_url = f"{config.cloud_host}/proxy"
|
||||
logger.info(f"Creating HTTP client for cloud proxy at: {proxy_base_url}")
|
||||
print(f"proxy_base_url: {proxy_base_url}")
|
||||
async with AsyncClient(
|
||||
base_url=proxy_base_url,
|
||||
headers={"Authorization": f"Bearer {token}"},
|
||||
|
||||
@@ -41,6 +41,8 @@ class CloudProjectCreateRequest(BaseModel):
|
||||
class CloudProjectCreateResponse(BaseModel):
|
||||
"""Response from creating a cloud project."""
|
||||
|
||||
name: str = Field(..., description="Created project name")
|
||||
path: str = Field(..., description="Created project path")
|
||||
message: str = Field(default="", description="Success message")
|
||||
message: str = Field(..., description="Status message about the project creation")
|
||||
status: str = Field(..., description="Status of the creation (success or error)")
|
||||
default: bool = Field(..., description="True if the project was set as the default")
|
||||
old_project: dict | None = Field(None, description="Information about the previous project")
|
||||
new_project: dict | None = Field(None, description="Information about the newly created project")
|
||||
|
||||
@@ -442,9 +442,11 @@ class TestCloudProjectAutoRegistration:
|
||||
mock_permalink.return_value = "my-new-project"
|
||||
mock_response = Mock()
|
||||
mock_response.json.return_value = {
|
||||
"name": "My New Project",
|
||||
"path": "my-new-project",
|
||||
"message": "Created",
|
||||
"message": "Project 'My New Project' added successfully",
|
||||
"status": "success",
|
||||
"default": False,
|
||||
"old_project": None,
|
||||
"new_project": {"name": "My New Project", "path": "my-new-project"},
|
||||
}
|
||||
mock_request.return_value = mock_response
|
||||
|
||||
|
||||
@@ -110,18 +110,20 @@ class TestCreateCloudProject:
|
||||
|
||||
mock_response = Mock()
|
||||
mock_response.json.return_value = {
|
||||
"name": "My Project",
|
||||
"path": "my-project",
|
||||
"message": "Created successfully",
|
||||
"message": "Project 'My Project' added successfully",
|
||||
"status": "success",
|
||||
"default": False,
|
||||
"old_project": None,
|
||||
"new_project": {"name": "My Project", "path": "my-project"},
|
||||
}
|
||||
mock_request.return_value = mock_response
|
||||
|
||||
result = await create_cloud_project("My Project")
|
||||
|
||||
# Verify result
|
||||
assert result.name == "My Project"
|
||||
assert result.path == "my-project"
|
||||
assert result.message == "Created successfully"
|
||||
assert result.message == "Project 'My Project' added successfully"
|
||||
assert result.status == "success"
|
||||
assert result.default is False
|
||||
|
||||
# Verify permalink was generated
|
||||
mock_permalink.assert_called_once_with("My Project")
|
||||
@@ -150,9 +152,11 @@ class TestCreateCloudProject:
|
||||
|
||||
mock_response = Mock()
|
||||
mock_response.json.return_value = {
|
||||
"name": "Test Project 123",
|
||||
"path": "test-project-123",
|
||||
"message": "Created",
|
||||
"message": "Project 'Test Project 123' added successfully",
|
||||
"status": "success",
|
||||
"default": False,
|
||||
"old_project": None,
|
||||
"new_project": {"name": "Test Project 123", "path": "test-project-123"},
|
||||
}
|
||||
mock_request.return_value = mock_response
|
||||
|
||||
@@ -191,9 +195,11 @@ class TestCreateCloudProject:
|
||||
|
||||
mock_response = Mock()
|
||||
mock_response.json.return_value = {
|
||||
"name": "Project",
|
||||
"path": "project",
|
||||
"message": "Created",
|
||||
"message": "Project 'Project' added successfully",
|
||||
"status": "success",
|
||||
"default": False,
|
||||
"old_project": None,
|
||||
"new_project": {"name": "Project", "path": "project"},
|
||||
}
|
||||
mock_request.return_value = mock_response
|
||||
|
||||
|
||||
Reference in New Issue
Block a user