test_account_export.py
python
sha256:f19d5e4a89766fc91b926cdf801255e12dcd968041c0ece8adf6627760788d22
merge: next build — MCP (#291 #292 #295 #324), profiles/sit…
Opus 5.5
minor
⚠ breaking
1 day ago
| 1 | """GET /api/me/export against a real database (musehub#307). |
| 2 | |
| 3 | The export used to 500 for any account that had created a repository: the commits section read a |
| 4 | ``repo_id`` attribute that ``MusehubCommit`` does not have (the commit-to-repo link is |
| 5 | ``MusehubCommitRef``). |
| 6 | """ |
| 7 | |
| 8 | from __future__ import annotations |
| 9 | |
| 10 | from httpx import AsyncClient |
| 11 | from sqlalchemy.ext.asyncio import AsyncSession |
| 12 | |
| 13 | |
| 14 | async def test_export_lists_repos_and_their_commits( |
| 15 | client: AsyncClient, db_session: AsyncSession, auth_headers: dict[str, str] |
| 16 | ) -> None: |
| 17 | created = await client.post( |
| 18 | "/api/repos", |
| 19 | json={"name": "export-me", "owner": "testuser", "visibility": "public", "initialize": True}, |
| 20 | headers=auth_headers, |
| 21 | ) |
| 22 | assert created.status_code in (200, 201), created.text |
| 23 | repo_id = created.json()["repoId"] |
| 24 | |
| 25 | response = await client.get("/api/me/export", headers=auth_headers) |
| 26 | assert response.status_code == 200, response.text |
| 27 | body = response.json() |
| 28 | assert body["identity"]["handle"] == "testuser" |
| 29 | assert [r["repo_id"] for r in body["repos"]] == [repo_id] |
| 30 | assert len(body["commits"]) == 1 |
| 31 | commit = body["commits"][0] |
| 32 | assert commit["repo_ids"] == [repo_id] |
| 33 | assert commit["commit_id"].startswith("sha256:") and commit["branch"] == "main" |
| 34 | |
| 35 | |
| 36 | async def test_export_for_an_account_without_repos( |
| 37 | client: AsyncClient, db_session: AsyncSession, auth_headers: dict[str, str] |
| 38 | ) -> None: |
| 39 | response = await client.get("/api/me/export", headers=auth_headers) |
| 40 | assert response.status_code == 200 |
| 41 | body = response.json() |
| 42 | assert body["repos"] == [] and body["commits"] == [] |
File History
3 commits
sha256:f19d5e4a89766fc91b926cdf801255e12dcd968041c0ece8adf6627760788d22
merge: next build — MCP (#291 #292 #295 #324), profiles/sit…
Opus 5.5
minor
⚠
1 day ago
sha256:7a1f4dfd571e937cb1032574d5c0965ba04ad520adcf523dec123d7a34746236
merge: rc26 — profiles/site wave (#119 #301 #303 #307 #314;…
Opus 5.5
minor
⚠
1 day ago
sha256:637e8821e77b2fef383d3020c15eafebaacd9d46ed7402e31aeba023b3a11ced
fix(export): GET /api/me/export no longer 500s for accounts…
Opus 5.5
patch
2 days ago