/ tests / agent / test_minimax_auxiliary_url.py
test_minimax_auxiliary_url.py
 1  """Tests for MiniMax auxiliary client URL normalization.
 2  
 3  MiniMax and MiniMax-CN set inference_base_url to the /anthropic path.
 4  The auxiliary client uses the OpenAI SDK, which needs /v1 instead.
 5  """
 6  
 7  import sys
 8  import os
 9  
10  sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
11  
12  from agent.auxiliary_client import _to_openai_base_url
13  
14  
15  class TestToOpenaiBaseUrl:
16      def test_minimax_global_anthropic_suffix_replaced(self):
17          assert _to_openai_base_url("https://api.minimax.io/anthropic") == "https://api.minimax.io/v1"
18  
19      def test_minimax_cn_anthropic_suffix_replaced(self):
20          assert _to_openai_base_url("https://api.minimaxi.com/anthropic") == "https://api.minimaxi.com/v1"
21  
22      def test_trailing_slash_stripped_before_replace(self):
23          assert _to_openai_base_url("https://api.minimax.io/anthropic/") == "https://api.minimax.io/v1"
24  
25      def test_v1_url_unchanged(self):
26          assert _to_openai_base_url("https://api.openai.com/v1") == "https://api.openai.com/v1"
27  
28      def test_openrouter_url_unchanged(self):
29          assert _to_openai_base_url("https://openrouter.ai/api/v1") == "https://openrouter.ai/api/v1"
30  
31      def test_anthropic_domain_unchanged(self):
32          """api.anthropic.com doesn't end with /anthropic — should be untouched."""
33          assert _to_openai_base_url("https://api.anthropic.com") == "https://api.anthropic.com"
34  
35      def test_anthropic_in_subpath_unchanged(self):
36          assert _to_openai_base_url("https://example.com/anthropic/extra") == "https://example.com/anthropic/extra"
37  
38      def test_empty_string(self):
39          assert _to_openai_base_url("") == ""
40  
41      def test_none(self):
42          assert _to_openai_base_url(None) == ""