@@ -800,7 +800,7 @@ async def test_refresh_managed_models_refreshes_minimax_token_plan_without_relog
800800
801801 with (
802802 patch (
803- "pythinker_code.auth.minimax._discover_minimax_models " ,
803+ "pythinker_code.auth.minimax.refresh_minimax_models " ,
804804 new = AsyncMock (return_value = discovered ),
805805 ),
806806 patch ("pythinker_code.auth.platforms.list_models" , new = AsyncMock ()) as list_models_mock ,
@@ -824,6 +824,41 @@ async def test_refresh_managed_models_refreshes_minimax_token_plan_without_relog
824824 assert "minimax/m2.7-highspeed" not in saved [0 ].models
825825
826826
827+ @pytest .mark .asyncio
828+ async def test_refresh_managed_models_applies_empty_minimax_catalog ():
829+ """An authenticated empty MiniMax catalog is authoritative and prunes stale models."""
830+ from pythinker_code .auth .minimax import MINIMAX_ANTHROPIC_PROVIDER_KEY
831+
832+ config = _make_minimax_config ()
833+ saved : list [Config ] = []
834+
835+ with (
836+ patch (
837+ "pythinker_code.auth.minimax.refresh_minimax_models" ,
838+ new = AsyncMock (return_value = ()),
839+ ) as refresh_mock ,
840+ patch ("pythinker_code.auth.platforms.list_models" , new = AsyncMock ()) as list_models_mock ,
841+ patch ("pythinker_code.auth.platforms.load_config" , side_effect = _make_minimax_config ),
842+ patch (
843+ "pythinker_code.auth.platforms.save_config" ,
844+ side_effect = lambda cfg , * a , ** k : saved .append (cfg ),
845+ ),
846+ ):
847+ changed = await refresh_managed_models (config )
848+
849+ assert changed is True
850+ assert refresh_mock .await_count == 1
851+ assert list_models_mock .await_count == 0
852+ assert not any (
853+ model .provider == MINIMAX_ANTHROPIC_PROVIDER_KEY for model in config .models .values ()
854+ )
855+ assert config .default_model == ""
856+ assert len (saved ) == 1
857+ assert not any (
858+ model .provider == MINIMAX_ANTHROPIC_PROVIDER_KEY for model in saved [0 ].models .values ()
859+ )
860+
861+
827862@pytest .mark .asyncio
828863async def test_refresh_managed_models_isolates_minimax_discovery_failure ():
829864 """MiniMax refresh failure must not abort other managed-provider refreshes."""
@@ -857,7 +892,7 @@ def _config_with_generic_provider() -> Config:
857892
858893 with (
859894 patch (
860- "pythinker_code.auth.minimax._discover_minimax_models " ,
895+ "pythinker_code.auth.minimax.refresh_minimax_models " ,
861896 new = AsyncMock (side_effect = aiohttp .ClientConnectionError ("offline" )),
862897 ),
863898 patch (
@@ -878,4 +913,6 @@ def _config_with_generic_provider() -> Config:
878913 assert changed is True
879914 assert len (saved ) == 1
880915 assert saved [0 ].models ["pythinker-code/pythinker-for-coding" ].max_context_size == 200_000
916+ assert "minimax/m2.7-highspeed" in saved [0 ].models
917+ assert saved [0 ].models ["minimax/m2.7-highspeed" ].provider == "managed:minimax-anthropic"
881918 assert "minimax/m2.7-highspeed" in config .models
0 commit comments