"""Regression test for `muse hub release list` (musehub staging #185 wrap-up). Found while confirming build versions before tagging a new release: `run_release_list` called `_hub_api(..., params=params)`, but `_hub_api` has no `params` keyword at all — every invocation of this command crashed with a TypeError before making any request. Completely untested until now. """ import argparse import json import pytest from muse.cli.commands.hub import releases as releases_mod class _FakeIdentity: pass class TestRunReleaseList: def test_limit_and_cursor_reach_the_request_url_as_query_params( self, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture, ) -> None: captured_urls: list[str] = [] def _fake_hub_api(hub_url, identity, method, path, body=None, timeout=10.0): captured_urls.append(path) return {"releases": [], "nextCursor": None, "total": 0} monkeypatch.setattr(releases_mod, "_hub_api", _fake_hub_api) monkeypatch.setattr( releases_mod, "_get_hub_and_identity", lambda hub_url_override=None: ("https://staging.musehub.ai/gabriel/muse", _FakeIdentity()), ) monkeypatch.setattr(releases_mod, "_resolve_repo_id", lambda hub_url, identity: "sha256:abc") args = argparse.Namespace(json_output=True, limit=10, cursor="tok123", hub=None) releases_mod.run_release_list(args) assert len(captured_urls) == 1 assert "limit=10" in captured_urls[0] assert "cursor=tok123" in captured_urls[0] def test_no_cursor_omits_cursor_param( self, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture, ) -> None: captured_urls: list[str] = [] def _fake_hub_api(hub_url, identity, method, path, body=None, timeout=10.0): captured_urls.append(path) return {"releases": [], "nextCursor": None, "total": 0} monkeypatch.setattr(releases_mod, "_hub_api", _fake_hub_api) monkeypatch.setattr( releases_mod, "_get_hub_and_identity", lambda hub_url_override=None: ("https://staging.musehub.ai/gabriel/muse", _FakeIdentity()), ) monkeypatch.setattr(releases_mod, "_resolve_repo_id", lambda hub_url, identity: "sha256:abc") args = argparse.Namespace(json_output=True, limit=50, cursor=None, hub=None) releases_mod.run_release_list(args) assert "cursor=" not in captured_urls[0] def test_json_output_includes_releases_from_response( self, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture, ) -> None: def _fake_hub_api(hub_url, identity, method, path, body=None, timeout=10.0): return {"releases": [{"tag": "v1.0.0"}], "nextCursor": None, "total": 1} monkeypatch.setattr(releases_mod, "_hub_api", _fake_hub_api) monkeypatch.setattr( releases_mod, "_get_hub_and_identity", lambda hub_url_override=None: ("https://staging.musehub.ai/gabriel/muse", _FakeIdentity()), ) monkeypatch.setattr(releases_mod, "_resolve_repo_id", lambda hub_url, identity: "sha256:abc") args = argparse.Namespace(json_output=True, limit=50, cursor=None, hub=None) releases_mod.run_release_list(args) out = json.loads(capsys.readouterr().out) assert out["releases"] == [{"tag": "v1.0.0"}]