Files
AstrBot/tests/test_event_bus.py
LIghtJUNction dcaaf6286a test: comprehensive test coverage and type fixes
- 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
2026-04-29 06:29:56 +08:00

43 lines
1.4 KiB
Python

"""Tests for astrbot.core.event_bus module."""
from asyncio import Queue
from unittest.mock import MagicMock
import pytest
from astrbot.core.event_bus import EventBus
from astrbot.core.astrbot_config_mgr import AstrBotConfigManager
from astrbot.core.pipeline.scheduler import PipelineScheduler
from astrbot.core.platform import AstrMessageEvent
class TestEventBus:
"""Smoke tests for EventBus."""
def test_module_import(self):
"""Verify the event_bus module can be imported."""
import astrbot.core.event_bus # noqa: F811
assert hasattr(
astrbot.core.event_bus,
"EventBus",
)
def test_class_exists(self):
"""Verify EventBus class exists."""
assert EventBus.__name__ == "EventBus"
def test_init_requires_three_args(self):
"""Verify EventBus init requires queue, scheduler mapping, and config manager."""
queue = Queue()
scheduler_mapping: dict[str, PipelineScheduler] = {}
config_mgr = MagicMock(spec=AstrBotConfigManager)
bus = EventBus(queue, scheduler_mapping, config_mgr)
assert bus.event_queue is queue
assert bus.pipeline_scheduler_mapping is scheduler_mapping
assert bus.astrbot_config_mgr is config_mgr
def test_has_dispatch_method(self):
"""Verify EventBus has a dispatch method."""
assert hasattr(EventBus, "dispatch")
assert callable(EventBus.dispatch)