mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 01:40:15 +08:00
- Add 100+ new test files covering provider sources, platform adapters, agent runners, star/plugin system, knowledge base, core utils, pipeline, computer tools, builtin commands, and dashboard routes - Fix Python type errors in sqlite.py (col() wrappers for SQLModel), astr_agent_tool_exec, core_lifecycle, star context/manager - Fix TypeScript strict mode errors across 30+ dashboard Vue files - Add import smoke tests, auth roundtrip, startup tests - Add compile-all check and CLI entry test for AUR compatibility - Restore BotMessageAccumulator and helpers lost in merge
51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
"""Import smoke tests for CozeAPIClient."""
|
|
|
|
import pytest
|
|
|
|
from astrbot.core.agent.runners.coze.coze_api_client import CozeAPIClient
|
|
|
|
|
|
class TestCozeAPIClientImport:
|
|
"""Verify CozeAPIClient can be imported and instantiated."""
|
|
|
|
def test_class_importable(self):
|
|
"""CozeAPIClient should be importable."""
|
|
assert CozeAPIClient is not None
|
|
|
|
def test_instantiation_with_defaults(self):
|
|
"""CozeAPIClient should be instantiatable with only api_key."""
|
|
client = CozeAPIClient(api_key="test-key")
|
|
assert isinstance(client, CozeAPIClient)
|
|
assert client.api_key == "test-key"
|
|
assert client.api_base == "https://api.coze.cn"
|
|
|
|
def test_instantiation_with_custom_base(self):
|
|
"""CozeAPIClient should accept a custom api_base."""
|
|
client = CozeAPIClient(api_key="test-key", api_base="https://custom.coze.com")
|
|
assert isinstance(client, CozeAPIClient)
|
|
assert client.api_base == "https://custom.coze.com"
|
|
|
|
def test_session_is_none_on_creation(self):
|
|
"""HTTP session should be None until _ensure_session is called."""
|
|
client = CozeAPIClient(api_key="test-key")
|
|
assert client.session is None
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_ensure_session_creates_session(self):
|
|
"""_ensure_session() should create an aiohttp ClientSession."""
|
|
import aiohttp
|
|
|
|
client = CozeAPIClient(api_key="test-key")
|
|
session = await client._ensure_session()
|
|
assert isinstance(session, aiohttp.ClientSession)
|
|
await client.close()
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_close_clears_session(self):
|
|
"""close() should clear the session."""
|
|
client = CozeAPIClient(api_key="test-key")
|
|
await client._ensure_session()
|
|
assert client.session is not None
|
|
await client.close()
|
|
assert client.session is None
|