Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test: keep the Qwen brand missing-key tests off the network and split the ChatGPT fields test back out

mateo-berribd8df0ed8f8f
diff --git a/tests/test_litellm/llms/dashscope/test_qwen_brand_aliases.py b/tests/test_litellm/llms/dashscope/test_qwen_brand_aliases.py
index 6f264ea1424..69ae66d3818 100644
--- a/tests/test_litellm/llms/dashscope/test_qwen_brand_aliases.py
+++ b/tests/test_litellm/llms/dashscope/test_qwen_brand_aliases.py
@@ -95,6 +95,13 @@ BRAND_CASES = [
def clear_dashscope_family_env(monkeypatch):
for env_var in DASHSCOPE_FAMILY_ENV_VARS:
monkeypatch.delenv(env_var, raising=False)
+ monkeypatch.setattr(litellm, "api_key", None)
+
+
+def no_provider_traffic(respx_mock, monkeypatch):
+ monkeypatch.setattr(litellm, "disable_aiohttp_transport", True)
+ return respx_mock
class TestQwenBrandProviderResolution:
@@ -267,22 +274,25 @@ class TestQwenBrandUserFacingNames:
assert self.RETIRED_MAINLAND_NAME not in message
@pytest.mark.parametrize("brand", BRAND_CASES)
- def test_embedding_without_key_names_brand(self, brand):
+ def test_embedding_without_key_names_brand(self, brand, no_provider_traffic):
with pytest.raises(litellm.APIConnectionError, match=re.escape(brand["display_name"])) as exc_info:
litellm.embedding(model=f"{brand['provider']}/text-embedding-v4", input=["hello"])
assert self.RETIRED_MAINLAND_NAME not in str(exc_info.value)
+ assert no_provider_traffic.calls.call_count == 0
@pytest.mark.parametrize("brand", BRAND_CASES)
- def test_rerank_without_key_names_brand(self, brand):
+ def test_rerank_without_key_names_brand(self, brand, no_provider_traffic):
with pytest.raises(litellm.APIConnectionError, match=re.escape(brand["display_name"])) as exc_info:
litellm.rerank(model=f"{brand['provider']}/gte-rerank-v2", query="q", documents=["a", "b"])
assert self.RETIRED_MAINLAND_NAME not in str(exc_info.value)
+ assert no_provider_traffic.calls.call_count == 0
@pytest.mark.parametrize("brand", BRAND_CASES)
- def test_image_generation_without_key_names_brand(self, brand):
+ def test_image_generation_without_key_names_brand(self, brand, no_provider_traffic):
with pytest.raises(litellm.APIConnectionError, match=re.escape(brand["display_name"])) as exc_info:
litellm.image_generation(model=f"{brand['provider']}/qwen-image", prompt="a cup of coffee")
assert self.RETIRED_MAINLAND_NAME not in str(exc_info.value)
+ assert no_provider_traffic.calls.call_count == 0
@pytest.mark.parametrize("brand", BRAND_CASES)
@pytest.mark.parametrize(
diff --git a/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py b/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py
index ba88fbd3951..0f1ff3b024d 100644
--- a/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py
+++ b/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py
@@ -357,6 +357,9 @@ def test_qwen_mainland_provider_fields_carry_the_qianwen_brand():
assert mainland_fields["api_key"]["label"] == "Qianwen AI Platform API Key"
assert "Qianwen AI Platform" in mainland_fields["api_base"]["tooltip"]
assert "Qwen AI Platform" not in json.dumps(mainland)
+
+
+def test_chatgpt_provider_fields():
app_instance = FastAPI()
app_instance.include_router(router)
test_client = TestClient(app_instance)