File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,9 +87,6 @@ def text_to_audio(
8787 format : str = DEFAULT_FORMAT ,
8888 language_boost : str = DEFAULT_LANGUAGE_BOOST ,
8989):
90- if not text :
91- raise MinimaxRequestError ("Text is required." )
92-
9390 payload = {
9491 "model" : model ,
9592 "text" : text ,
@@ -111,6 +108,9 @@ def text_to_audio(
111108 if resource_mode == RESOURCE_MODE_URL :
112109 payload ["output_format" ] = "url"
113110 try :
111+ if not text :
112+ raise MinimaxRequestError ("Text is required." )
113+
114114 response_data = api_client .post ("/v1/t2a_v2" , json = payload )
115115 audio_data = response_data .get ('data' , {}).get ('audio' , '' )
116116
Original file line number Diff line number Diff line change 1+ import importlib
2+ import sys
3+
4+ from mcp .types import TextContent
5+
6+
7+ def load_server (monkeypatch ):
8+ monkeypatch .setenv ("MINIMAX_API_KEY" , "test-key" )
9+ monkeypatch .setenv ("MINIMAX_API_HOST" , "https://api.example.com" )
10+ sys .modules .pop ("minimax_mcp.server" , None )
11+ return importlib .import_module ("minimax_mcp.server" )
12+
13+
14+ def test_text_to_audio_returns_text_content_for_empty_text (monkeypatch ):
15+ server = load_server (monkeypatch )
16+
17+ result = server .text_to_audio (text = "" )
18+
19+ assert isinstance (result , TextContent )
20+ assert result .type == "text"
21+ assert result .text == "Failed to generate audio: Text is required."
You can’t perform that action at this time.
0 commit comments