gabriel / musehub public
test_ui_user_profile_no_commit_meta.py python
84 lines 2.6 KB
Raw
sha256:a34090cc4a394a78bd72cbbe34b08cc59525141e19135b6c0ab154f10611b9ef debug(push/stream): instrument O-frame decode path with INF… Sonnet 4.6 patch 121 days ago
1 """TDD — ui_user_profile 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 muse.core.types import blob_id
9 from musehub.db import musehub_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) -> db.MusehubCommit:
18 row = db.MusehubCommit(
19 commit_id=blob_id(seed.encode()),
20 repo_id=repo_id,
21 branch="dev",
22 parent_ids=[],
23 message=f"feat: {seed}",
24 author="gabriel",
25 timestamp=_utc(),
26 **kwargs,
27 )
28 session.add(row)
29 await session.commit()
30 return row
31
32
33 # ---------------------------------------------------------------------------
34 # UP1 — user profile route does not crash with AttributeError on commit_meta
35 # ---------------------------------------------------------------------------
36
37 @pytest.mark.asyncio
38 async def test_up1_user_profile_no_commit_meta_error(
39 db_session: AsyncSession,
40 client,
41 auth_headers,
42 ) -> None:
43 """User profile page must not raise AttributeError on commit_meta JSON path queries."""
44 repo = await create_repo(db_session, owner="gabriel", visibility="public")
45 await _add_commit(
46 db_session, repo.repo_id, "up-human-c1",
47 agent_id="", model_id="",
48 )
49 await _add_commit(
50 db_session, repo.repo_id, "up-agent-c1",
51 agent_id="claude-code", model_id="claude-sonnet-4-6",
52 )
53
54 resp = await client.get(
55 "/gabriel",
56 headers=auth_headers,
57 follow_redirects=True,
58 )
59 assert resp.status_code != 500
60
61
62 # ---------------------------------------------------------------------------
63 # UP2 — agent profile route does not crash with AttributeError on commit_meta
64 # ---------------------------------------------------------------------------
65
66 @pytest.mark.asyncio
67 async def test_up2_agent_profile_no_commit_meta_error(
68 db_session: AsyncSession,
69 client,
70 auth_headers,
71 ) -> None:
72 """Agent profile page must not raise AttributeError on commit_meta JSON path queries."""
73 repo = await create_repo(db_session, owner="gabriel", visibility="public")
74 await _add_commit(
75 db_session, repo.repo_id, "up-agent-prof-c1",
76 agent_id="claude-code", model_id="claude-sonnet-4-6",
77 )
78
79 resp = await client.get(
80 "/claude-code",
81 headers=auth_headers,
82 follow_redirects=True,
83 )
84 assert resp.status_code != 500
File History 1 commit
sha256:a34090cc4a394a78bd72cbbe34b08cc59525141e19135b6c0ab154f10611b9ef debug(push/stream): instrument O-frame decode path with INF… Sonnet 4.6 patch 121 days ago