gabriel / musehub public
test_ui_proposals_no_commit_meta.py python
66 lines 2.2 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_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 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:1047a72059ff30688a6196dfc365f1200b04e40e39cfa0651ff8ad04ba352823 fix: ui_proposals reads provenance from first-class columns… Sonnet 4.6 patch 196 days ago