fix: repair all test fixtures - add missing solution fields and fix httpx API
- Add missing `solution` field to solution-type nodes in test tree structures (required by `can_publish_tree` validation for published trees) - Fix `AsyncClient(app=...)` → `ASGITransport(app=...)` in test_save_session_as_tree (httpx deprecated the `app` parameter in favor of transport) - All 189 tests now pass (was 84 passed, 1 failed) Files fixed: conftest.py, test_permissions_account.py, test_subscription_limits.py, test_trees.py, test_save_session_as_tree.py Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -174,13 +174,15 @@ async def test_tree(client, auth_headers):
|
|||||||
"id": "solution1",
|
"id": "solution1",
|
||||||
"type": "solution",
|
"type": "solution",
|
||||||
"title": "Test Confirmed",
|
"title": "Test Confirmed",
|
||||||
"description": "This is a test tree"
|
"description": "This is a test tree",
|
||||||
|
"solution": "Test confirmed - this is a test tree"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "solution2",
|
"id": "solution2",
|
||||||
"type": "solution",
|
"type": "solution",
|
||||||
"title": "Not a Test",
|
"title": "Not a Test",
|
||||||
"description": "This should not happen"
|
"description": "This should not happen",
|
||||||
|
"solution": "Not a test - this should not happen"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class TestAccountPermissions:
|
|||||||
# Try to create tree
|
# Try to create tree
|
||||||
response = await client.post("/api/v1/trees", json={
|
response = await client.post("/api/v1/trees", json={
|
||||||
"name": "Viewer Tree",
|
"name": "Viewer Tree",
|
||||||
"tree_structure": {"id": "root", "type": "solution", "title": "Test", "description": "Test"}
|
"tree_structure": {"id": "root", "type": "solution", "title": "Test", "description": "Test", "solution": "Test solution"}
|
||||||
}, headers=viewer_headers)
|
}, headers=viewer_headers)
|
||||||
assert response.status_code == 403
|
assert response.status_code == 403
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ class TestAccountPermissions:
|
|||||||
# Create a public tree as the regular user first
|
# Create a public tree as the regular user first
|
||||||
await client.post("/api/v1/trees", json={
|
await client.post("/api/v1/trees", json={
|
||||||
"name": "Public Tree",
|
"name": "Public Tree",
|
||||||
"tree_structure": {"id": "root", "type": "solution", "title": "T", "description": "T"},
|
"tree_structure": {"id": "root", "type": "solution", "title": "T", "description": "T", "solution": "Test solution"},
|
||||||
"is_public": True
|
"is_public": True
|
||||||
}, headers=auth_headers)
|
}, headers=auth_headers)
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ class TestAccountPermissions:
|
|||||||
# Engineer creates a tree
|
# Engineer creates a tree
|
||||||
tree_resp = await client.post("/api/v1/trees", json={
|
tree_resp = await client.post("/api/v1/trees", json={
|
||||||
"name": "Engineer's Tree",
|
"name": "Engineer's Tree",
|
||||||
"tree_structure": {"id": "root", "type": "solution", "title": "T", "description": "T"}
|
"tree_structure": {"id": "root", "type": "solution", "title": "T", "description": "T", "solution": "Test solution"}
|
||||||
}, headers=eng_headers)
|
}, headers=eng_headers)
|
||||||
assert tree_resp.status_code == 201
|
assert tree_resp.status_code == 201
|
||||||
tree_id = tree_resp.json()["id"]
|
tree_id = tree_resp.json()["id"]
|
||||||
@@ -143,7 +143,7 @@ class TestAccountPermissions:
|
|||||||
# Owner creates a private tree
|
# Owner creates a private tree
|
||||||
tree_resp = await client.post("/api/v1/trees", json={
|
tree_resp = await client.post("/api/v1/trees", json={
|
||||||
"name": "Private Account Tree",
|
"name": "Private Account Tree",
|
||||||
"tree_structure": {"id": "root", "type": "solution", "title": "T", "description": "T"},
|
"tree_structure": {"id": "root", "type": "solution", "title": "T", "description": "T", "solution": "Test solution"},
|
||||||
"is_public": False
|
"is_public": False
|
||||||
}, headers=auth_headers)
|
}, headers=auth_headers)
|
||||||
assert tree_resp.status_code == 201
|
assert tree_resp.status_code == 201
|
||||||
@@ -181,7 +181,7 @@ class TestAccountPermissions:
|
|||||||
# Owner creates a private tree
|
# Owner creates a private tree
|
||||||
tree_resp = await client.post("/api/v1/trees", json={
|
tree_resp = await client.post("/api/v1/trees", json={
|
||||||
"name": "Secret Tree",
|
"name": "Secret Tree",
|
||||||
"tree_structure": {"id": "root", "type": "solution", "title": "T", "description": "T"},
|
"tree_structure": {"id": "root", "type": "solution", "title": "T", "description": "T", "solution": "Test solution"},
|
||||||
"is_public": False
|
"is_public": False
|
||||||
}, headers=auth_headers)
|
}, headers=auth_headers)
|
||||||
assert tree_resp.status_code == 201
|
assert tree_resp.status_code == 201
|
||||||
|
|||||||
@@ -362,8 +362,8 @@ class TestSaveSessionAsTreeAPI:
|
|||||||
await test_db.refresh(session)
|
await test_db.refresh(session)
|
||||||
|
|
||||||
# Try to save the session as test_user (should fail - filtered by user_id)
|
# Try to save the session as test_user (should fail - filtered by user_id)
|
||||||
from httpx import AsyncClient
|
from httpx import AsyncClient, ASGITransport
|
||||||
async with AsyncClient(app=client._transport.app, base_url="http://test") as test_client: # type: ignore
|
async with AsyncClient(transport=ASGITransport(app=client._transport.app), base_url="http://test") as test_client: # type: ignore
|
||||||
# Login as test_user
|
# Login as test_user
|
||||||
login_response = await test_client.post(
|
login_response = await test_client.post(
|
||||||
"/api/v1/auth/login",
|
"/api/v1/auth/login",
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ class TestSubscriptionLimits:
|
|||||||
"id": "root",
|
"id": "root",
|
||||||
"type": "solution",
|
"type": "solution",
|
||||||
"title": "Test",
|
"title": "Test",
|
||||||
"description": "Test tree"
|
"description": "Test tree",
|
||||||
|
"solution": "Test solution"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +51,8 @@ class TestSubscriptionLimits:
|
|||||||
"id": "root",
|
"id": "root",
|
||||||
"type": "solution",
|
"type": "solution",
|
||||||
"title": "Test",
|
"title": "Test",
|
||||||
"description": "Test"
|
"description": "Test",
|
||||||
|
"solution": "Test solution"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
create_resp = await client.post("/api/v1/trees", json=tree_data, headers=auth_headers)
|
create_resp = await client.post("/api/v1/trees", json=tree_data, headers=auth_headers)
|
||||||
@@ -73,7 +75,8 @@ class TestSubscriptionLimits:
|
|||||||
"id": "root",
|
"id": "root",
|
||||||
"type": "solution",
|
"type": "solution",
|
||||||
"title": "Test",
|
"title": "Test",
|
||||||
"description": "Test tree"
|
"description": "Test tree",
|
||||||
|
"solution": "Test solution"
|
||||||
},
|
},
|
||||||
"is_default": True # Default trees skip limit check
|
"is_default": True # Default trees skip limit check
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ class TestTrees:
|
|||||||
"id": "check_cable",
|
"id": "check_cable",
|
||||||
"type": "solution",
|
"type": "solution",
|
||||||
"title": "Check Network Cable",
|
"title": "Check Network Cable",
|
||||||
"description": "Verify the network cable is connected"
|
"description": "Verify the network cable is connected",
|
||||||
|
"solution": "Check and reseat the network cable"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -189,7 +190,8 @@ class TestTrees:
|
|||||||
"id": "root",
|
"id": "root",
|
||||||
"type": "solution",
|
"type": "solution",
|
||||||
"title": "Private",
|
"title": "Private",
|
||||||
"description": "Private tree"
|
"description": "Private tree",
|
||||||
|
"solution": "Private solution"
|
||||||
},
|
},
|
||||||
"is_public": False,
|
"is_public": False,
|
||||||
"is_default": False
|
"is_default": False
|
||||||
@@ -220,7 +222,8 @@ class TestTrees:
|
|||||||
"id": "root",
|
"id": "root",
|
||||||
"type": "solution",
|
"type": "solution",
|
||||||
"title": "Test",
|
"title": "Test",
|
||||||
"description": "Test tree"
|
"description": "Test tree",
|
||||||
|
"solution": "Test solution"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
create_resp = await client.post("/api/v1/trees", json=tree_data, headers=auth_headers)
|
create_resp = await client.post("/api/v1/trees", json=tree_data, headers=auth_headers)
|
||||||
@@ -337,7 +340,8 @@ class TestTrees:
|
|||||||
"id": "root",
|
"id": "root",
|
||||||
"type": "solution",
|
"type": "solution",
|
||||||
"title": "Test",
|
"title": "Test",
|
||||||
"description": "Test tree"
|
"description": "Test tree",
|
||||||
|
"solution": "Test solution"
|
||||||
}
|
}
|
||||||
response = await client.post("/api/v1/trees", json=tree_data, headers=auth_headers)
|
response = await client.post("/api/v1/trees", json=tree_data, headers=auth_headers)
|
||||||
assert response.status_code == 201
|
assert response.status_code == 201
|
||||||
|
|||||||
Reference in New Issue
Block a user