summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Bielik <martin.bielik@instea.sk>2024-12-16 23:46:17 +0100
committerMartin Bielik <martin.bielik@instea.sk>2024-12-16 23:46:17 +0100
commit8fde389664ca59773c38dc0ec1a434a98bc2428b (patch)
tree9cfd732f0c9c8820b6d2c3fce945fa8c266ec92d /tests
parent2a418adca13bc7f8d4b35a4a1ec83fe0e5aedd91 (diff)
downloadvim-ai-8fde389664ca59773c38dc0ec1a434a98bc2428b.tar.gz
command-type only roles
Diffstat (limited to '')
-rw-r--r--tests/context_test.py11
-rw-r--r--tests/resources/roles.ini3
-rw-r--r--tests/roles_test.py16
3 files changed, 27 insertions, 3 deletions
diff --git a/tests/context_test.py b/tests/context_test.py
index 1e179f1..9f7d004 100644
--- a/tests/context_test.py
+++ b/tests/context_test.py
@@ -115,6 +115,17 @@ def test_multiple_role_configs():
assert 'https://localhost/chat' == actual_config['options']['endpoint_url']
assert 'simple role prompt:\nhello' == actual_prompt
+def test_chat_only_role():
+ context = make_ai_context({
+ 'config_default': default_config,
+ 'config_extension': {},
+ 'user_instruction': '/chat-only-role',
+ 'user_selection': '',
+ 'command_type': 'chat',
+ })
+ actual_config = context['config']
+ assert 'preset_tab' == actual_config['options']['open_chat_command']
+
def test_user_prompt():
assert 'fix grammar: helo word' == make_prompt( '', 'fix grammar: helo word', '', '')
assert 'fix grammar:\nhelo word' == make_prompt( '', 'fix grammar', 'helo word', '')
diff --git a/tests/resources/roles.ini b/tests/resources/roles.ini
index 16335d3..450df1d 100644
--- a/tests/resources/roles.ini
+++ b/tests/resources/roles.ini
@@ -15,6 +15,9 @@ config.options.endpoint_url = https://localhost/complete
config.engine = complete
config.options.endpoint_url = https://localhost/edit
+[chat-only-role.chat]
+config.options.open_chat_command = preset_tab
+
[deprecated-test-role-simple]
prompt = simple role prompt
[deprecated-test-role-simple.options]
diff --git a/tests/roles_test.py b/tests/roles_test.py
index 3230329..ac5525d 100644
--- a/tests/roles_test.py
+++ b/tests/roles_test.py
@@ -1,10 +1,20 @@
from roles import load_ai_role_names
def test_role_completion():
- role_names = load_ai_role_names()
- assert role_names == [
+ role_names = load_ai_role_names('complete')
+ assert set(role_names) == {
'test-role-simple',
'test-role',
'deprecated-test-role-simple',
'deprecated-test-role',
- ]
+ }
+
+def test_role_chat_only():
+ role_names = load_ai_role_names('chat')
+ assert set(role_names) == {
+ 'test-role-simple',
+ 'test-role',
+ 'chat-only-role',
+ 'deprecated-test-role-simple',
+ 'deprecated-test-role',
+ }