Skip to content

Commit 0880cab

Browse files
committed
add test
1 parent 9f0f842 commit 0880cab

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
import sys
3+
4+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src")))
5+
6+
from envs.textarena_env.server.environment import TextArenaEnvironment
7+
from envs.textarena_env.models import TextArenaMessage
8+
9+
10+
def test_convert_messages_coalesces_consecutive_characters():
11+
env = object.__new__(TextArenaEnvironment)
12+
13+
raw_messages = [
14+
(0, "[", "PROMPT"),
15+
(0, "GAME", "PROMPT"),
16+
(0, "]", "PROMPT"),
17+
(1, "A", "MESSAGE"),
18+
(1, "B", "MESSAGE"),
19+
(2, "!", "MESSAGE"),
20+
]
21+
22+
converted = env._convert_messages(raw_messages)
23+
24+
assert converted == [
25+
TextArenaMessage(sender_id=0, content="[GAME]", category="PROMPT"),
26+
TextArenaMessage(sender_id=1, content="AB", category="MESSAGE"),
27+
TextArenaMessage(sender_id=2, content="!", category="MESSAGE"),
28+
]

0 commit comments

Comments
 (0)