From d840a7c5a745068a317f98dcd9170e0d00850784 Mon Sep 17 00:00:00 2001 From: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> Date: Wed, 18 Oct 2023 15:46:21 +0800 Subject: [PATCH] Update tests/test_rule.py --- tests/test_rule.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/test_rule.py b/tests/test_rule.py index e3af0193ccb4..4bf1a22f171e 100644 --- a/tests/test_rule.py +++ b/tests/test_rule.py @@ -113,7 +113,7 @@ async def test_trie(app: App): command_whitespace=" ", ) - message = FakeMessageSegment.text("/fake-prefix") + FakeMessageSegment.text( + message = FakeMessageSegment.text("/fake-prefix ") + FakeMessageSegment.text( " some args" ) event = make_fake_event(_message=message)() @@ -124,7 +124,23 @@ async def test_trie(app: App): raw_command="/fake-prefix", command_arg=FakeMessage("some args"), command_start="/", - command_whitespace=" ", + command_whitespace=" ", + ) + + message = ( + FakeMessageSegment.text("/fake-prefix ") + + FakeMessageSegment.text(" ") + + FakeMessageSegment.text(" some args") + ) + event = make_fake_event(_message=message)() + state = {} + TrieRule.get_value(bot, event, state) + assert state[PREFIX_KEY] == CMD_RESULT( + command=("fake-prefix",), + raw_command="/fake-prefix", + command_arg=FakeMessage("some args"), + command_start="/", + command_whitespace=" ", ) del TrieRule.prefix["/fake-prefix"]