gabriel / musehub public
test_ui_repo_no_commit_meta.py python
89 lines 3.0 KB
Raw
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595 fix: typing audit — 0 violations, 0 untyped defs across all… Sonnet 4.6 minor ⚠ breaking 21 days ago
1 """TDD — ui_repo commit enrichment 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_repo_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 branch="dev",
21 parent_ids=[],
22 message=f"feat: {seed}",
23 author="gabriel",
24 timestamp=_utc(),
25 **kwargs,
26 )
27 session.add(row)
28 session.add(db.MusehubCommitRef(repo_id=repo_id, commit_id=row.commit_id))
29 await session.commit()
30 return row
31
32
33 # ---------------------------------------------------------------------------
34 # R1 — ORM row has first-class columns, not commit_meta
35 # ---------------------------------------------------------------------------
36
37 @pytest.mark.asyncio
38 async def test_r1_musehub_commit_has_no_commit_meta_attribute(
39 db_session: AsyncSession,
40 ) -> None:
41 """MusehubCommit ORM row must expose agent_id/sem_ver_bump/etc. and not commit_meta."""
42 repo = await create_repo(db_session, owner="gabriel", visibility="public")
43 row = await _add_commit(
44 db_session, repo.repo_id, "repo-col-check",
45 agent_id="claude-code", model_id="claude-sonnet-4-6",
46 sem_ver_bump="minor", breaking_changes=[], toolchain_id="muse-1",
47 test_runs=2, reviewed_by=[],
48 )
49 await db_session.refresh(row)
50
51 assert not hasattr(row, "commit_meta"), "commit_meta must not exist on ORM row"
52 assert row.agent_id == "claude-code"
53 assert row.model_id == "claude-sonnet-4-6"
54 assert row.sem_ver_bump == "minor"
55 assert row.test_runs == 2
56 assert row.toolchain_id == "muse-1"
57
58
59 # ---------------------------------------------------------------------------
60 # R2 — route GET /owner/slug does not crash with AttributeError
61 # ---------------------------------------------------------------------------
62
63 @pytest.mark.asyncio
64 async def test_r2_repo_route_no_commit_meta_error(
65 db_session: AsyncSession,
66 client,
67 auth_headers,
68 ) -> None:
69 """Repo page must not raise AttributeError on commit_meta when enriching commits."""
70 repo = await create_repo(db_session, owner="gabriel", visibility="public")
71 commit = await _add_commit(
72 db_session, repo.repo_id, "repo-route-c1",
73 agent_id="claude-code", model_id="claude-sonnet-4-6",
74 sem_ver_bump="patch",
75 )
76 db_session.add(db.MusehubBranch(
77 branch_id=blob_id(b"repo-route-branch"),
78 repo_id=repo.repo_id,
79 name="dev",
80 head_commit_id=commit.commit_id,
81 ))
82 await db_session.commit()
83
84 resp = await client.get(
85 f"/gabriel/{repo.slug}",
86 headers=auth_headers,
87 follow_redirects=True,
88 )
89 assert resp.status_code == 200
File History 1 commit
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595 fix: typing audit — 0 violations, 0 untyped defs across all… Sonnet 4.6 minor 21 days ago