gabriel / musehub public
test_ui_blame_no_commit_meta.py python
67 lines 2.1 KB Cold
Raw
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595 fix: typing audit — 0 violations, 0 untyped defs across all… Sonnet 4.6 minor ⚠ breaking 172 days ago
1 """TDD — ui_blame commit loading must not read commit_meta."""
2 from __future__ import annotations
3
4 import typing
5 from collections.abc import Mapping
6 from datetime import datetime, timezone
7
8 import pytest
9 from httpx import AsyncClient
10 from muse.core.types import blob_id
11 from sqlalchemy.ext.asyncio import AsyncSession
12
13 from musehub.db import musehub_repo_models as db
14 from tests.factories import create_repo
15
16
17 def _utc() -> datetime:
18 return datetime.now(tz=timezone.utc)
19
20
21 async def _add_commit(session: AsyncSession, repo_id: str, seed: str, **kwargs: typing.Any) -> db.MusehubCommit:
22 row = db.MusehubCommit(
23 commit_id=blob_id(seed.encode()),
24 branch="dev",
25 parent_ids=[],
26 message=f"feat: {seed}",
27 author="gabriel",
28 timestamp=_utc(),
29 **kwargs,
30 )
31 session.add(row)
32 session.add(db.MusehubCommitRef(repo_id=repo_id, commit_id=row.commit_id))
33 await session.commit()
34 return row
35
36
37 # ---------------------------------------------------------------------------
38 # BL1 — blame route does not crash with AttributeError on commit_meta
39 # ---------------------------------------------------------------------------
40
41 @pytest.mark.asyncio
42 async def test_bl1_blame_route_no_commit_meta_error(
43 db_session: AsyncSession,
44 client: AsyncClient,
45 auth_headers: Mapping[str, str],
46 ) -> None:
47 """Blame page must not raise AttributeError on commit_meta."""
48 repo = await create_repo(db_session, owner="gabriel", visibility="public")
49 commit = await _add_commit(
50 db_session, repo.repo_id, "blame-c1",
51 agent_id="claude-code", model_id="claude-sonnet-4-6",
52 )
53 db_session.add(db.MusehubBranch(
54 branch_id=blob_id(b"blame-branch"),
55 repo_id=repo.repo_id,
56 name="dev",
57 head_commit_id=commit.commit_id,
58 ))
59 await db_session.commit()
60
61 resp = await client.get(
62 f"/gabriel/{repo.slug}/blame/dev/src/app.py",
63 headers=auth_headers,
64 follow_redirects=True,
65 )
66 # 200 or 404 (no snapshot/file) — anything but 500
67 assert resp.status_code != 500
File History 6 commits
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595 fix: typing audit — 0 violations, 0 untyped defs across all… Sonnet 4.6 minor ⚠ 172 days ago
sha256:b8884c81af5e135510894a537784c16158ee9c2c05d074f978611bbcb611ca10 fix: port security checks inline, remove repo_id from Museh… Sonnet 4.6 minor ⚠ 181 days ago
sha256:2e9f6b5cc193e07b2c23d17fb71851db72e6160ba472013f5bccab8351264e79 refactor: migrate all musehub_models shim call sites to dom… Sonnet 4.6 minor ⚠ 188 days ago
sha256:3a29a6fd5c0da6ed1e40a498f5c491bee45c684b34936b55e64be6b76413cb52 refactor(tests): eliminate _sha/_sha256_oid/_blob_id wrappe… Sonnet 4.6 196 days ago
sha256:7918558cb69109fcd34288d56f1937ef56f739f117e9ed22bd8c8b8bf8e9567e refactor: route all sha256 ID construction through long_id(… Sonnet 4.6 patch 196 days ago
sha256:74a6e19cd6517d96dae39ba3fbe99111f15bf12bbf29ef97705aa4226cd884bf fix: ui_blame reads provenance from first-class columns, dr… Sonnet 4.6 patch 196 days ago