gabriel / musehub public
test_users_no_commit_meta.py python
54 lines 1.9 KB
Raw
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595 fix: typing audit — 0 violations, 0 untyped defs across all… Sonnet 4.6 minor ⚠ breaking 21 days ago
1 """TDD — users agent listing must not query via commit_meta JSON path."""
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 musehub.db import musehub_repo_models as db
9 from tests.factories import create_repo
10 from muse.core.types import blob_id
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) -> None:
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
31
32 # ---------------------------------------------------------------------------
33 # U1 — agent card listing queries agent_id column, not commit_meta JSON path
34 # ---------------------------------------------------------------------------
35
36 @pytest.mark.asyncio
37 async def test_u1_agent_listing_uses_column_not_json_path(
38 db_session: AsyncSession,
39 ) -> None:
40 from musehub.api.routes.musehub.users import _query_agent_fleet
41
42 repo = await create_repo(db_session, owner="gabriel", visibility="public")
43 await _add_commit(db_session, repo.repo_id, "usr-agent-c1",
44 agent_id="claude-code", model_id="claude-sonnet-4-6")
45 await _add_commit(db_session, repo.repo_id, "usr-agent-c2",
46 agent_id="claude-code", model_id="claude-sonnet-4-6")
47 await _add_commit(db_session, repo.repo_id, "usr-human-c1",
48 agent_id="", model_id="")
49
50 results = await _query_agent_fleet(db_session, "gabriel", repo.owner_user_id)
51
52 assert len(results) == 1
53 assert results[0].agent_id == "claude-code"
54 assert results[0].commit_count == 2
File History 1 commit
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595 fix: typing audit — 0 violations, 0 untyped defs across all… Sonnet 4.6 minor 21 days ago