gabriel / musehub public
test_ui_proposals_no_commit_meta.py python
66 lines 2.2 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_proposals 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: typing.Any) -> 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 await session.refresh(row)
31 return row
32
33
34 # ---------------------------------------------------------------------------
35 # P1 — ORM row has all columns the proposal enrichment loop needs
36 # ---------------------------------------------------------------------------
37
38 @pytest.mark.asyncio
39 async def test_p1_proposal_commit_orm_columns(
40 db_session: AsyncSession,
41 ) -> None:
42 """MusehubCommit row must have sem_ver_bump/agent_id/model_id/signature/breaking_changes."""
43 repo = await create_repo(db_session, owner="gabriel", visibility="public")
44 row = await _add_commit(
45 db_session, repo.repo_id, "prop-c1",
46 agent_id="claude-code", model_id="claude-sonnet-4-6",
47 sem_ver_bump="minor", breaking_changes=["src/api.py::handler"],
48 signature="ed25519:SIG",
49 )
50
51 assert not hasattr(row, "commit_meta")
52
53 # Simulate the two enrichment loops in ui_proposals.py
54 bump = str(row.sem_ver_bump or "none").lower()
55 bc = row.breaking_changes
56 breaking = [str(x) for x in bc if x] if isinstance(bc, list) else []
57
58 agent_id = str(row.agent_id or "")
59 model_id = str(row.model_id or "")
60 is_signed = bool(row.signature)
61
62 assert bump == "minor"
63 assert breaking == ["src/api.py::handler"]
64 assert agent_id == "claude-code"
65 assert model_id == "claude-sonnet-4-6"
66 assert is_signed is True
File History 1 commit
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595 fix: typing audit — 0 violations, 0 untyped defs across all… Sonnet 4.6 minor 21 days ago