test_docs_getting_started_version.py
file-level
1
files
1
commits
0
hotspots
0
🧊 dead
0
💥 blast risk
| 1 | """TDD — musehub#191 (acceptance criterion 3): the "muse --version" sample |
| 2 | output on /muse/getting-started must show the real installable muse CLI |
| 3 | tarball version, not musehub's own unrelated app version. |
| 4 | |
| 5 | The page's example output block used the global Jinja variable |
| 6 | MUSE_VERSION, which despite its name is musehub.protocol.version.MUSE_VERSION |
| 7 | -- musehub's own package version (importlib.metadata.version("musehub")), |
| 8 | completely independent of the actual muse CLI tarball install.sh serves |
| 9 | (muse and musehub version independently; see docs/deploy.md). The correct |
| 10 | source is install.py's _latest_published_muse_version(), which scans the |
| 11 | real releases directory for the most recently published muse-*.tar.gz. |
| 12 | """ |
| 13 | from __future__ import annotations |
| 14 | |
| 15 | from unittest.mock import patch |
| 16 | |
| 17 | import pytest |
| 18 | from httpx import AsyncClient |
| 19 | |
| 20 | |
| 21 | class TestGettingStartedVersionDisplay: |
| 22 | @pytest.mark.asyncio |
| 23 | async def test_shows_latest_published_muse_version_not_musehub_app_version( |
| 24 | self, client: AsyncClient |
| 25 | ) -> None: |
| 26 | from musehub.protocol.version import MUSE_VERSION |
| 27 | |
| 28 | with patch( |
| 29 | "musehub.api.routes.musehub.ui_docs._latest_published_muse_version", |
| 30 | return_value="9.9.9-fake-muse-cli-version", |
| 31 | ): |
| 32 | r = await client.get("/muse/getting-started") |
| 33 | assert r.status_code == 200 |
| 34 | assert "muse 9.9.9-fake-muse-cli-version" in r.text |
| 35 | # The regression this fixes: musehub's own app version must not |
| 36 | # leak into this specific example-output block. |
| 37 | if MUSE_VERSION != "9.9.9-fake-muse-cli-version": |
| 38 | assert f"muse {MUSE_VERSION}" not in r.text |
| 39 | |
| 40 | @pytest.mark.asyncio |
| 41 | async def test_falls_back_cleanly_when_no_tarballs_published( |
| 42 | self, client: AsyncClient |
| 43 | ) -> None: |
| 44 | """When no releases exist yet, the real function's own documented |
| 45 | fallback (musehub's app version) still renders a valid page.""" |
| 46 | r = await client.get("/muse/getting-started") |
| 47 | assert r.status_code == 200 |
| 48 | assert "muse --version" in r.text |