gabriel / musehub public
test_ui_blame_no_commit_meta.py python
63 lines 1.9 KB
Raw
sha256:a34090cc4a394a78bd72cbbe34b08cc59525141e19135b6c0ab154f10611b9ef debug(push/stream): instrument O-frame decode path with INF… Sonnet 4.6 patch 122 days ago
1 """TDD — ui_blame commit loading must not read commit_meta."""
2 from __future__ import annotations
3
4 import pytest
5 from datetime import datetime, timezone
6 from sqlalchemy.ext.asyncio import AsyncSession
7
8 from muse.core.types import blob_id
9 from musehub.db import musehub_models as db
10 from tests.factories import create_repo
11
12
13 def _utc() -> datetime:
14 return datetime.now(tz=timezone.utc)
15
16
17 async def _add_commit(session: AsyncSession, repo_id: str, seed: str, **kwargs) -> db.MusehubCommit:
18 row = db.MusehubCommit(
19 commit_id=blob_id(seed.encode()),
20 repo_id=repo_id,
21 branch="dev",
22 parent_ids=[],
23 message=f"feat: {seed}",
24 author="gabriel",
25 timestamp=_utc(),
26 **kwargs,
27 )
28 session.add(row)
29 await session.commit()
30 return row
31
32
33 # ---------------------------------------------------------------------------
34 # BL1 — blame route does not crash with AttributeError on commit_meta
35 # ---------------------------------------------------------------------------
36
37 @pytest.mark.asyncio
38 async def test_bl1_blame_route_no_commit_meta_error(
39 db_session: AsyncSession,
40 client,
41 auth_headers,
42 ) -> None:
43 """Blame page must not raise AttributeError on commit_meta."""
44 repo = await create_repo(db_session, owner="gabriel", visibility="public")
45 commit = await _add_commit(
46 db_session, repo.repo_id, "blame-c1",
47 agent_id="claude-code", model_id="claude-sonnet-4-6",
48 )
49 db_session.add(db.MusehubBranch(
50 branch_id=blob_id(b"blame-branch"),
51 repo_id=repo.repo_id,
52 name="dev",
53 head_commit_id=commit.commit_id,
54 ))
55 await db_session.commit()
56
57 resp = await client.get(
58 f"/gabriel/{repo.slug}/blame/dev/src/app.py",
59 headers=auth_headers,
60 follow_redirects=True,
61 )
62 # 200 or 404 (no snapshot/file) — anything but 500
63 assert resp.status_code != 500
File History 1 commit
sha256:a34090cc4a394a78bd72cbbe34b08cc59525141e19135b6c0ab154f10611b9ef debug(push/stream): instrument O-frame decode path with INF… Sonnet 4.6 patch 122 days ago