Files
AstrBot/tests_v4/test_api_modules.py
whatevertogo 4694f250ba Refactor tests and add integration tests for runtime module
- Added integration tests for the runtime module covering subprocess lifecycle, concurrency, and real-world scenarios in `test_runtime_integration.py`.
- Updated existing test files to include a blank line after module docstrings for consistency.
- Enhanced `test_protocol_legacy_adapter.py` with additional assertions for message output.
- Modified `test_transport.py` to use concrete transport implementations for abstract method tests.
- Improved test cases for handling timeouts and remote handler tracking in `test_timeout_handling.py` and `test_peer_remote_handlers.py`.
2026-03-13 02:18:36 +08:00

77 lines
2.3 KiB
Python

"""
Tests for API module exports and re-exports.
"""
from __future__ import annotations
class TestApiStarModule:
"""Tests for api/star module exports."""
def test_star_module_exports_context(self):
"""api.star should export Context."""
from astrbot_sdk.api.star import Context
assert Context is not None
def test_star_context_is_legacy_context(self):
"""api.star.Context should be LegacyContext."""
from astrbot_sdk._legacy_api import LegacyContext
from astrbot_sdk.api.star import Context
assert Context is LegacyContext
class TestApiComponentsModule:
"""Tests for api/components module exports."""
def test_components_module_exports_command_component(self):
"""api.components should export CommandComponent."""
from astrbot_sdk.api.components import CommandComponent
assert CommandComponent is not None
def test_command_component_is_from_legacy_api(self):
"""api.components.CommandComponent should be from _legacy_api."""
from astrbot_sdk._legacy_api import CommandComponent as LegacyCommandComponent
from astrbot_sdk.api.components import CommandComponent
assert CommandComponent is LegacyCommandComponent
class TestApiEventModule:
"""Tests for api/event module exports."""
def test_event_module_exports(self):
"""api.event should export expected names."""
from astrbot_sdk.api.event import ADMIN, AstrMessageEvent, filter
assert ADMIN == "admin"
assert filter is not None
assert AstrMessageEvent is not None
def test_astr_message_event_is_message_event(self):
"""AstrMessageEvent should be MessageEvent."""
from astrbot_sdk.api.event import AstrMessageEvent
from astrbot_sdk.events import MessageEvent
assert AstrMessageEvent is MessageEvent
def test_all_exports(self):
"""api.event should export all expected names."""
from astrbot_sdk.api.event import __all__
assert "ADMIN" in __all__
assert "AstrMessageEvent" in __all__
assert "filter" in __all__
class TestApiModule:
"""Tests for top-level api module."""
def test_api_module_exists(self):
"""api module should be importable."""
import astrbot_sdk.api
assert astrbot_sdk.api is not None