test_proposals_no_commit_meta.py
python
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595
fix: typing audit — 0 violations, 0 untyped defs across all…
Sonnet 4.6
minor
⚠ breaking
22 days ago
| 1 | """TDD — musehub_proposals must not access commit_meta (dropped in migration 0020).""" |
| 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.musehub_repo_models import MusehubBranch, MusehubCommit, MusehubCommitRef |
| 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) -> MusehubCommit: |
| 18 | row = MusehubCommit( |
| 19 | commit_id=blob_id(seed.encode()), |
| 20 | branch="feat/x", |
| 21 | parent_ids=[], |
| 22 | message=f"feat: {seed}", |
| 23 | author="gabriel", |
| 24 | timestamp=_utc(), |
| 25 | **kwargs, |
| 26 | ) |
| 27 | session.add(row) |
| 28 | session.add(MusehubCommitRef(repo_id=repo_id, commit_id=row.commit_id)) |
| 29 | session.add(MusehubBranch( |
| 30 | branch_id=blob_id(f"br-{seed}".encode()), |
| 31 | repo_id=repo_id, |
| 32 | name="feat/x", |
| 33 | head_commit_id=row.commit_id, |
| 34 | )) |
| 35 | await session.commit() |
| 36 | return row |
| 37 | |
| 38 | |
| 39 | # --------------------------------------------------------------------------- |
| 40 | # PR1 — _touched_symbols_for_branch does not crash on missing commit_meta |
| 41 | # --------------------------------------------------------------------------- |
| 42 | |
| 43 | @pytest.mark.asyncio |
| 44 | async def test_pr1_touched_symbols_no_commit_meta( |
| 45 | db_session: AsyncSession, |
| 46 | ) -> None: |
| 47 | """_touched_symbols_for_branch must not raise AttributeError on commit_meta.""" |
| 48 | from musehub.services.musehub_proposals import _touched_symbols_for_branch |
| 49 | |
| 50 | repo = await create_repo(db_session, owner="gabriel", visibility="public") |
| 51 | await _add_commit(db_session, repo.repo_id, "pr1-c1", agent_id="claude-code") |
| 52 | |
| 53 | # Must not raise — returns [] since structured_delta is gone |
| 54 | result = await _touched_symbols_for_branch(db_session, repo.repo_id, "feat/x") |
| 55 | assert isinstance(result, list) |
File History
1 commit
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595
fix: typing audit — 0 violations, 0 untyped defs across all…
Sonnet 4.6
minor
⚠
22 days ago