Files

68 lines
1.9 KiB
Python
Raw Permalink Normal View History

from types import SimpleNamespace
from unittest.mock import Mock
2026-06-13 01:34:09 +08:00
from src.bot.orchestrator import _register_handlers
from src.bot.runtime_coordinator import RuntimeStatus
2026-06-13 01:34:09 +08:00
class RecordingBot:
def __init__(self):
self.command_handlers = []
2026-06-13 01:34:09 +08:00
def message_handler(self, *args, **kwargs):
commands = kwargs.get("commands")
if commands:
self.command_handlers.extend(commands)
2026-06-13 01:34:09 +08:00
def _decorator(func):
return func
2026-06-13 01:34:09 +08:00
return _decorator
2026-06-13 01:34:09 +08:00
def chat_join_request_handler(self, *args, **kwargs):
def _decorator(func):
return func
2026-06-13 01:34:09 +08:00
return _decorator
2026-06-13 01:34:09 +08:00
def callback_query_handler(self, *args, **kwargs):
def _decorator(func):
return func
2026-06-13 01:34:09 +08:00
return _decorator
2026-06-13 01:34:09 +08:00
def test_register_handlers_does_not_expose_removed_query_commands():
bot = RecordingBot()
io_layer = SimpleNamespace(
build_welcome_text=Mock(return_value="WELCOME"),
build_points_rank_text=Mock(return_value="TOP"),
track_group_text_activity=Mock(),
)
2026-06-13 01:34:09 +08:00
startup_coordinator = SimpleNamespace(
get_runtime_status=Mock(
return_value=RuntimeStatus(
started_at="2026-06-13 00:00:00 UTC",
loops=[],
command_access_mode="public",
protected_commands=[],
required_group_chat_id="",
)
)
)
2026-06-13 01:34:09 +08:00
_register_handlers(
2026-03-20 20:59:30 +08:00
bot=bot,
2026-06-13 01:34:09 +08:00
config={},
2026-03-20 20:59:30 +08:00
io_layer=io_layer,
2026-06-13 01:34:09 +08:00
guard=SimpleNamespace(),
city_service=SimpleNamespace(),
deb_service=SimpleNamespace(),
startup_coordinator=startup_coordinator,
2026-03-20 20:59:30 +08:00
)
2026-06-13 01:34:09 +08:00
assert "city" not in bot.command_handlers
assert "pwcity" not in bot.command_handlers
assert "deb" not in bot.command_handlers
assert "pwdeb" not in bot.command_handlers
assert "markets" not in bot.command_handlers