-
Notifications
You must be signed in to change notification settings - Fork 43
/
test_messages_builder.py
64 lines (52 loc) · 2.01 KB
/
test_messages_builder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import unittest
from copilot.context import Context
from copilot.conversation import Model
from copilot.messages_builder import system_messages, system_prompt_message
from copilot.parse_os import OperatingSystem
from copilot.sample_conversations import unix_fish_sample_conversations, unix_bourne_sample_conversations, \
windows_cmd_sample_conversations
class TestSystemMessages(unittest.TestCase):
def _create_context(self, os, shell):
return Context(
shell=shell,
operating_system=os,
directory="path/to/directory",
directory_list=["dir1", "dir2"],
history="command history",
command="test command",
git="git status",
model=Model.GPT_35_TURBO,
)
def test_system_messages_unix_fish(self):
# arrange
context = self._create_context(OperatingSystem.MACOS, "path/to/fish")
# act
result = system_messages(context)
# assert
for message in unix_fish_sample_conversations():
self.assertIn(message, result)
def test_system_messages_unix_bourne(self):
# arrange
context = self._create_context(OperatingSystem.LINUX, "path/to/bash")
# act
result = system_messages(context)
# assert
for message in unix_bourne_sample_conversations():
self.assertIn(message, result)
def test_system_messages_windows(self):
# arrange
context = self._create_context(OperatingSystem.WINDOWS, "path/to/cmd")
# act
result = system_messages(context)
# assert
for message in windows_cmd_sample_conversations():
self.assertIn(message, result)
def test_contains_system_prompt_message(self):
# arrange
context = self._create_context(OperatingSystem.WINDOWS, "path/to/cmd")
# act
result = system_messages(context)
# assert
self.assertIn(system_prompt_message(context), result)
if __name__ == '__main__':
unittest.main()