Skip to content

Commit c090ebe

Browse files
jope-bmclaude
andcommitted
Add test for display_name in project list table
Verifies that private projects with display_name show "My Project" in the Name column instead of the raw UUID. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Joe P <joe@basicmemory.com>
1 parent ea72cb1 commit c090ebe

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

tests/cli/test_project_list_and_ls.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,77 @@ async def fake_list_projects(self):
139139
assert "/beta" in result.stdout
140140

141141

142+
def test_project_list_shows_display_name_for_private_projects(
143+
runner: CliRunner, write_config, mock_client, tmp_path, monkeypatch
144+
):
145+
"""Private projects should show display_name ('My Project') instead of raw UUID name."""
146+
private_uuid = "f1df8f39-d5aa-4095-ae05-8c5a2883029a"
147+
148+
write_config(
149+
{
150+
"env": "dev",
151+
"projects": {},
152+
"default_project": "main",
153+
"cloud_api_key": "bmc_test_key_123",
154+
}
155+
)
156+
157+
local_payload = {
158+
"projects": [
159+
{
160+
"id": 1,
161+
"external_id": "11111111-1111-1111-1111-111111111111",
162+
"name": "main",
163+
"path": "/main",
164+
"is_default": True,
165+
}
166+
],
167+
"default_project": "main",
168+
}
169+
170+
cloud_payload = {
171+
"projects": [
172+
{
173+
"id": 1,
174+
"external_id": "11111111-1111-1111-1111-111111111111",
175+
"name": "main",
176+
"path": "/main",
177+
"is_default": True,
178+
},
179+
{
180+
"id": 2,
181+
"external_id": "22222222-2222-2222-2222-222222222222",
182+
"name": private_uuid,
183+
"path": f"/{private_uuid}",
184+
"is_default": False,
185+
"display_name": "My Project",
186+
"is_private": True,
187+
},
188+
],
189+
"default_project": "main",
190+
}
191+
192+
async def fake_list_projects(self):
193+
if os.getenv("BASIC_MEMORY_FORCE_CLOUD", "").lower() in ("true", "1", "yes"):
194+
return ProjectList.model_validate(cloud_payload)
195+
return ProjectList.model_validate(local_payload)
196+
197+
monkeypatch.setattr(ProjectClient, "list_projects", fake_list_projects)
198+
199+
result = runner.invoke(app, ["project", "list"], env={"COLUMNS": "240"})
200+
201+
assert result.exit_code == 0, f"Exit code: {result.exit_code}, output: {result.stdout}"
202+
# display_name should appear in the Name column instead of the raw UUID
203+
assert "My Project" in result.stdout
204+
# The Name column should show "My Project", not the UUID.
205+
# The UUID may still appear in the Cloud Path column — that's expected.
206+
lines = result.stdout.splitlines()
207+
project_line = next(line for line in lines if "My Project" in line)
208+
# The name cell is the first column — verify UUID is not the displayed name
209+
name_cell = project_line.split("│")[1].strip()
210+
assert name_cell == "My Project"
211+
212+
142213
def test_project_ls_local_mode_defaults_to_local_route(
143214
runner: CliRunner, write_config, mock_client, tmp_path, monkeypatch
144215
):

0 commit comments

Comments
 (0)