gabriel / musehub public
test_ui_user_profile_no_commit_meta.py python
88 lines 2.8 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_user_profile must not query via commit_meta JSON path."""
2 from __future__ import annotations
3
4 import typing
5 from collections.abc import Mapping
6 from datetime import datetime, timezone
7
8 import pytest
9 from httpx import AsyncClient
10 from muse.core.types import blob_id
11 from sqlalchemy.ext.asyncio import AsyncSession
12
13 from musehub.db import musehub_repo_models as db
14 from tests.factories import create_repo
15
16
17 def _utc() -> datetime:
18 return datetime.now(tz=timezone.utc)
19
20
21 async def _add_commit(session: AsyncSession, repo_id: str, seed: str, **kwargs: typing.Any) -> db.MusehubCommit:
22 row = db.MusehubCommit(
23 commit_id=blob_id(seed.encode()),
24 branch="dev",
25 parent_ids=[],
26 message=f"feat: {seed}",
27 author="gabriel",
28 timestamp=_utc(),
29 **kwargs,
30 )
31 session.add(row)
32 session.add(db.MusehubCommitRef(repo_id=repo_id, commit_id=row.commit_id))
33 await session.commit()
34 return row
35
36
37 # ---------------------------------------------------------------------------
38 # UP1 — user profile route does not crash with AttributeError on commit_meta
39 # ---------------------------------------------------------------------------
40
41 @pytest.mark.asyncio
42 async def test_up1_user_profile_no_commit_meta_error(
43 db_session: AsyncSession,
44 client: AsyncClient,
45 auth_headers: Mapping[str, str],
46 ) -> None:
47 """User profile page must not raise AttributeError on commit_meta JSON path queries."""
48 repo = await create_repo(db_session, owner="gabriel", visibility="public")
49 await _add_commit(
50 db_session, repo.repo_id, "up-human-c1",
51 agent_id="", model_id="",
52 )
53 await _add_commit(
54 db_session, repo.repo_id, "up-agent-c1",
55 agent_id="claude-code", model_id="claude-sonnet-4-6",
56 )
57
58 resp = await client.get(
59 "/gabriel",
60 headers=auth_headers,
61 follow_redirects=True,
62 )
63 assert resp.status_code != 500
64
65
66 # ---------------------------------------------------------------------------
67 # UP2 — agent profile route does not crash with AttributeError on commit_meta
68 # ---------------------------------------------------------------------------
69
70 @pytest.mark.asyncio
71 async def test_up2_agent_profile_no_commit_meta_error(
72 db_session: AsyncSession,
73 client: AsyncClient,
74 auth_headers: Mapping[str, str],
75 ) -> None:
76 """Agent profile page must not raise AttributeError on commit_meta JSON path queries."""
77 repo = await create_repo(db_session, owner="gabriel", visibility="public")
78 await _add_commit(
79 db_session, repo.repo_id, "up-agent-prof-c1",
80 agent_id="claude-code", model_id="claude-sonnet-4-6",
81 )
82
83 resp = await client.get(
84 "/claude-code",
85 headers=auth_headers,
86 follow_redirects=True,
87 )
88 assert resp.status_code != 500
File History 1 commit
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595 fix: typing audit — 0 violations, 0 untyped defs across all… Sonnet 4.6 minor 21 days ago