|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +"""Unit tests for QiniuChatModel.""" |
| 4 | + |
| 5 | +import pytest |
| 6 | + |
| 7 | +from openjudge.models import QiniuChatModel |
| 8 | +from openjudge.models.qiniu_chat_model import QINIU_MODELS |
| 9 | + |
| 10 | + |
| 11 | +@pytest.mark.unit |
| 12 | +class TestQiniuChatModelInit: |
| 13 | + """Verify constructor defaults and argument handling.""" |
| 14 | + |
| 15 | + def test_default_base_url(self): |
| 16 | + model = QiniuChatModel(api_key="test-key") |
| 17 | + assert model.client.base_url is not None |
| 18 | + assert "qnaigc.com" in str(model.client.base_url) |
| 19 | + |
| 20 | + def test_default_model(self): |
| 21 | + model = QiniuChatModel(api_key="test-key") |
| 22 | + assert model.model == "deepseek-v3" |
| 23 | + |
| 24 | + def test_qiniu_models_contains_deepseek_v3(self): |
| 25 | + assert "deepseek-v3" in QINIU_MODELS |
| 26 | + |
| 27 | + def test_api_key_from_env(self, monkeypatch): |
| 28 | + monkeypatch.setenv("QINIU_API_KEY", "env-key-123") |
| 29 | + model = QiniuChatModel() |
| 30 | + assert model.client.api_key == "env-key-123" |
| 31 | + |
| 32 | + def test_explicit_api_key_overrides_env(self, monkeypatch): |
| 33 | + monkeypatch.setenv("QINIU_API_KEY", "env-key") |
| 34 | + model = QiniuChatModel(api_key="explicit-key") |
| 35 | + assert model.client.api_key == "explicit-key" |
| 36 | + |
| 37 | + def test_custom_base_url(self): |
| 38 | + model = QiniuChatModel(api_key="k", base_url="https://custom.qnaigc.com/v1") |
| 39 | + assert "custom.qnaigc.com" in str(model.client.base_url) |
| 40 | + |
| 41 | + |
| 42 | +@pytest.mark.unit |
| 43 | +class TestQiniuChatModelInheritance: |
| 44 | + """Verify class hierarchy and exported symbols.""" |
| 45 | + |
| 46 | + def test_inherits_from_openai_chat_model(self): |
| 47 | + from openjudge.models.openai_chat_model import OpenAIChatModel |
| 48 | + |
| 49 | + assert issubclass(QiniuChatModel, OpenAIChatModel) |
| 50 | + |
| 51 | + def test_exported_from_models_package(self): |
| 52 | + from openjudge.models import QiniuChatModel as Imported |
| 53 | + |
| 54 | + assert Imported is QiniuChatModel |
0 commit comments