Skip to content

Commit 50c7669

Browse files
committed
fix: Use cross-platform paths in idempotency tests
Use tempfile.TemporaryDirectory() instead of hardcoded /tmp path to fix Windows test failures. The test was failing on Windows because /tmp was converted to D:/tmp, causing path comparison to fail. Also use Path.resolve() for cross-platform path normalization in assertions. Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 35977fe commit 50c7669

1 file changed

Lines changed: 30 additions & 28 deletions

File tree

tests/api/test_project_router.py

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -562,40 +562,42 @@ async def test_set_nonexistent_project_as_default_fails(test_config, client, pro
562562
@pytest.mark.asyncio
563563
async def test_create_project_idempotent_same_path(test_config, client, project_service):
564564
"""Test that creating a project with same name and same path is idempotent."""
565-
# Create a project
565+
# Create a project with platform-independent path
566566
test_project_name = "test-idempotent"
567-
test_project_path = "/tmp/test-idempotent"
567+
with tempfile.TemporaryDirectory() as temp_dir:
568+
test_project_path = (Path(temp_dir) / "test-idempotent").as_posix()
568569

569-
response1 = await client.post(
570-
"/projects/projects",
571-
json={"name": test_project_name, "path": test_project_path, "set_default": False},
572-
)
570+
response1 = await client.post(
571+
"/projects/projects",
572+
json={"name": test_project_name, "path": test_project_path, "set_default": False},
573+
)
573574

574-
# Should succeed with 201 Created
575-
assert response1.status_code == 201
576-
data1 = response1.json()
577-
assert data1["status"] == "success"
578-
assert data1["new_project"]["name"] == test_project_name
575+
# Should succeed with 201 Created
576+
assert response1.status_code == 201
577+
data1 = response1.json()
578+
assert data1["status"] == "success"
579+
assert data1["new_project"]["name"] == test_project_name
579580

580-
# Try to create the same project again with same name and path
581-
response2 = await client.post(
582-
"/projects/projects",
583-
json={"name": test_project_name, "path": test_project_path, "set_default": False},
584-
)
581+
# Try to create the same project again with same name and path
582+
response2 = await client.post(
583+
"/projects/projects",
584+
json={"name": test_project_name, "path": test_project_path, "set_default": False},
585+
)
585586

586-
# Should also succeed (idempotent)
587-
assert response2.status_code == 200
588-
data2 = response2.json()
589-
assert data2["status"] == "success"
590-
assert "already exists" in data2["message"]
591-
assert data2["new_project"]["name"] == test_project_name
592-
assert data2["new_project"]["path"] == test_project_path
587+
# Should also succeed (idempotent)
588+
assert response2.status_code == 200
589+
data2 = response2.json()
590+
assert data2["status"] == "success"
591+
assert "already exists" in data2["message"]
592+
assert data2["new_project"]["name"] == test_project_name
593+
# Normalize paths for cross-platform comparison
594+
assert Path(data2["new_project"]["path"]).resolve() == Path(test_project_path).resolve()
593595

594-
# Clean up
595-
try:
596-
await project_service.remove_project(test_project_name)
597-
except Exception:
598-
pass
596+
# Clean up
597+
try:
598+
await project_service.remove_project(test_project_name)
599+
except Exception:
600+
pass
599601

600602

601603
@pytest.mark.asyncio

0 commit comments

Comments
 (0)