Creator App Tests / PR Spam Gate (push) Skipped
Frontend Tests / PR Spam Gate (push) Skipped
NPM Format (website & console) / PR Spam Gate (push) Skipped
Pre-commit Checks / PR Spam Gate (push) Skipped
QwenPaw Creator Plugin Release / check-version (push) Canceled after 0s
QwenPaw Creator Plugin Release / upload-oss (push) Canceled after 0s
Tests / PR Spam Gate (push) Skipped
CodeQL / CodeQL (python) (push) Canceled after 0s
CodeQL / CodeQL (typescript) (push) Canceled after 0s
Creator App Tests / Creator Backend Tests (push) Canceled after 0s
Creator App Tests / Creator UI Build & Tests (push) Canceled after 0s
E2E Smoke Tests / Playwright UI Smoke (push) Canceled after 0s
Frontend Tests / Detect console changes (push) Canceled after 0s
NPM Format (website & console) / website format check (push) Canceled after 0s
NPM Format (website & console) / console format check (push) Canceled after 0s
Pre-commit Checks / Pre-commit (push) Canceled after 0s
QwenPaw Data Plugin Release / check-version (push) Canceled after 0s
Tests / Detect code changes (push) Canceled after 0s
Frontend Tests / Vitest Unit Tests (push) Canceled after 0s
Frontend Tests / Frontend Summary (push) Canceled after 0s
QwenPaw Data Plugin Release / upload-oss (push) Canceled after 0s
Tests / Maintainer Approval (push) Canceled after 0s
Tests / Unit Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - fallback (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p2 (push) Canceled after 0s
Tests / Coverage Report (push) Canceled after 0s
Tests / Test Summary (push) Canceled after 0s
96 lines
3.3 KiB
Python
96 lines
3.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# pylint: disable=redefined-outer-name,unused-argument,protected-access
|
|
"""Tests for the SiliconFlow built-in providers."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from types import SimpleNamespace
|
|
|
|
import pytest
|
|
|
|
import qwenpaw.providers.provider_manager as provider_manager_module
|
|
from qwenpaw.providers.openai_provider import OpenAIProvider
|
|
from qwenpaw.providers.provider_manager import (
|
|
PROVIDER_SILICONFLOW_CN,
|
|
PROVIDER_SILICONFLOW_INTL,
|
|
ProviderManager,
|
|
)
|
|
|
|
|
|
def test_siliconflow_providers_are_openai_compatible() -> None:
|
|
"""Siliconflow providers should be OpenAIProvider instances."""
|
|
assert isinstance(PROVIDER_SILICONFLOW_CN, OpenAIProvider)
|
|
assert isinstance(PROVIDER_SILICONFLOW_INTL, OpenAIProvider)
|
|
|
|
|
|
def test_siliconflow_provider_configs() -> None:
|
|
"""Verify Siliconflow provider configuration defaults."""
|
|
assert PROVIDER_SILICONFLOW_CN.id == "siliconflow-cn"
|
|
assert PROVIDER_SILICONFLOW_CN.name == "SiliconFlow (China)"
|
|
assert PROVIDER_SILICONFLOW_CN.base_url == "https://api.siliconflow.cn/v1"
|
|
assert PROVIDER_SILICONFLOW_CN.freeze_url is True
|
|
assert PROVIDER_SILICONFLOW_CN.support_model_discovery is True
|
|
|
|
assert PROVIDER_SILICONFLOW_INTL.id == "siliconflow-intl"
|
|
assert PROVIDER_SILICONFLOW_INTL.name == "SiliconFlow (International)"
|
|
assert (
|
|
PROVIDER_SILICONFLOW_INTL.base_url == "https://api.siliconflow.com/v1"
|
|
)
|
|
assert PROVIDER_SILICONFLOW_INTL.freeze_url is True
|
|
assert PROVIDER_SILICONFLOW_INTL.support_model_discovery is True
|
|
|
|
|
|
def test_siliconflow_models_list() -> None:
|
|
"""Verify Siliconflow has no preset models (empty list)."""
|
|
assert not PROVIDER_SILICONFLOW_CN.models
|
|
assert not PROVIDER_SILICONFLOW_INTL.models
|
|
assert len(PROVIDER_SILICONFLOW_CN.models) == 0
|
|
assert len(PROVIDER_SILICONFLOW_INTL.models) == 0
|
|
|
|
|
|
@pytest.fixture
|
|
def isolated_secret_dir(monkeypatch, tmp_path):
|
|
secret_dir = tmp_path / ".qwenpaw.secret"
|
|
monkeypatch.setattr(provider_manager_module, "SECRET_DIR", secret_dir)
|
|
return secret_dir
|
|
|
|
|
|
def test_siliconflow_registered_in_provider_manager(
|
|
isolated_secret_dir,
|
|
) -> None:
|
|
"""Siliconflow providers should be registered as built-in providers."""
|
|
manager = ProviderManager()
|
|
|
|
provider_cn = manager.get_provider("siliconflow-cn")
|
|
assert provider_cn is not None
|
|
assert isinstance(provider_cn, OpenAIProvider)
|
|
assert provider_cn.base_url == "https://api.siliconflow.cn/v1"
|
|
|
|
provider_intl = manager.get_provider("siliconflow-intl")
|
|
assert provider_intl is not None
|
|
assert isinstance(provider_intl, OpenAIProvider)
|
|
assert provider_intl.base_url == "https://api.siliconflow.com/v1"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_siliconflow_check_connection_success(monkeypatch) -> None:
|
|
"""Siliconflow check_connection should delegate to OpenAI client."""
|
|
provider = OpenAIProvider(
|
|
id="siliconflow-cn",
|
|
name="SiliconFlow (China)",
|
|
base_url="https://api.siliconflow.cn/v1",
|
|
api_key="test-key",
|
|
)
|
|
|
|
class FakeModels:
|
|
async def list(self, timeout=None):
|
|
return SimpleNamespace(data=[])
|
|
|
|
fake_client = SimpleNamespace(models=FakeModels())
|
|
monkeypatch.setattr(provider, "_client", lambda timeout=5: fake_client)
|
|
|
|
ok, msg = await provider.check_connection(timeout=2)
|
|
|
|
assert ok is True
|
|
assert msg == ""
|