gabriel / musehub public
test_mcp_executor_no_commit_meta.py python
82 lines 2.8 KB
Raw
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595 fix: typing audit — 0 violations, 0 untyped defs across all… Sonnet 4.6 minor ⚠ breaking 20 days ago
1 """TDD — musehub_mcp_executor must not access commit_meta (dropped in migration 0020)."""
2 from __future__ import annotations
3
4 import pytest
5 from muse.core.types import blob_id
6 from datetime import datetime, timezone
7 from sqlalchemy.ext.asyncio import AsyncSession
8
9 from musehub.db.musehub_repo_models import MusehubBranch, MusehubCommit, MusehubCommitRef
10 from musehub.db.musehub_social_models import MusehubProposal
11 from tests.factories import create_repo
12
13
14 def _utc() -> datetime:
15 return datetime.now(tz=timezone.utc)
16
17
18 async def _add_commit(session: AsyncSession, repo_id: str, seed: str, **kwargs: typing.Any) -> MusehubCommit:
19 row = MusehubCommit(
20 commit_id=blob_id(seed.encode()),
21 branch="feat/mcp",
22 parent_ids=[],
23 message=f"feat: {seed}",
24 author="gabriel",
25 timestamp=_utc(),
26 **kwargs,
27 )
28 session.add(row)
29 session.add(MusehubCommitRef(repo_id=repo_id, commit_id=row.commit_id))
30 session.add(MusehubBranch(
31 branch_id=blob_id(f"br-{seed}".encode()),
32 repo_id=repo_id,
33 name="feat/mcp",
34 head_commit_id=row.commit_id,
35 ))
36 await session.commit()
37 return row
38
39
40 async def _add_proposal(session: AsyncSession, repo_id: str, seed: str) -> MusehubProposal:
41 from musehub.core.genesis import compute_proposal_id
42 proposal_id = blob_id(f"proposal-{seed}".encode())
43 row = MusehubProposal(
44 proposal_id=proposal_id,
45 proposal_number=1,
46 repo_id=repo_id,
47 title=f"proposal {seed}",
48 body="",
49 state="open",
50 from_branch="feat/mcp",
51 to_branch="dev",
52 author="gabriel",
53 created_at=_utc(),
54 )
55 session.add(row)
56 await session.commit()
57 return row
58
59
60 # ---------------------------------------------------------------------------
61 # MCP1 — _extract_proposal_symbol_data does not crash on commit_meta
62 # ---------------------------------------------------------------------------
63
64 @pytest.mark.asyncio
65 async def test_mcp1_extract_proposal_symbol_data_no_commit_meta(
66 db_session: AsyncSession,
67 ) -> None:
68 """_extract_proposal_symbol_data must not raise AttributeError on commit_meta."""
69 from musehub.services.musehub_mcp_executor import _extract_proposal_symbol_data
70
71 repo = await create_repo(db_session, owner="gabriel", visibility="public")
72 await _add_commit(
73 db_session, repo.repo_id, "mcp1-c1",
74 agent_id="claude-code", model_id="claude-sonnet-4-6",
75 signature="ed25519:abc",
76 )
77 proposal = await _add_proposal(db_session, repo.repo_id, "mcp1")
78
79 # Must not raise — returns None or a tuple
80 result = await _extract_proposal_symbol_data(db_session, repo.repo_id, proposal.proposal_id)
81 # None is acceptable (no commits on from_branch linked to proposal yet)
82 assert result is None or isinstance(result, tuple)
File History 1 commit
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595 fix: typing audit — 0 violations, 0 untyped defs across all… Sonnet 4.6 minor 20 days ago