| 123456789101112131415161718192021222324252627282930 |
- from __future__ import annotations
- import pytest
- @pytest.mark.parametrize(
- ("text", "expected"),
- [
- ("封禁", ("/ban", ["ban"])),
- ("解封", ("/unban", ["unban"])),
- ("禁言", ("/mute", ["mute"])),
- ("解除禁言", ("/unmute", ["unmute"])),
- ("警告", ("/warn", ["warn"])),
- ("禁言10分钟", ("/tmute 10m", ["tmute", "10m"])),
- ("禁言 2 小时", ("/tmute 2h", ["tmute", "2h"])),
- ("禁言1天", ("/tmute 1d", ["tmute", "1d"])),
- ("踢出", ("/kick", ["kick"])),
- ("踢", ("/kick", ["kick"])),
- ("飞", ("/kick", ["kick"])),
- ],
- )
- def test_member_action_shortcut_parser(app_modules, text, expected):
- shortcuts = app_modules.load("wbb.services.member_shortcuts")
- assert shortcuts.member_action_shortcut_command(text) == expected
- @pytest.mark.parametrize("text", ["禁言0分钟", "禁言100分钟", "封禁 原因", "踢他"])
- def test_member_action_shortcut_rejects_ambiguous_text(app_modules, text):
- shortcuts = app_modules.load("wbb.services.member_shortcuts")
- assert shortcuts.member_action_shortcut_command(text) is None
|