From 082eb061b9233719a4c763905008a17d636b468f Mon Sep 17 00:00:00 2001 From: Martin Bielik Date: Mon, 16 Dec 2024 20:14:56 +0100 Subject: edit command role --- tests/context_test.py | 24 +++++++++++++----------- tests/resources/roles.ini | 2 ++ 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/context_test.py b/tests/context_test.py index 16c6e10..869215d 100644 --- a/tests/context_test.py +++ b/tests/context_test.py @@ -67,34 +67,36 @@ def test_role_config(): assert 'simple role prompt:\nuser instruction:\nselected text' == actual_prompt def test_role_config_different_commands(): - context = make_ai_context({ + base = { 'config_default': default_config, 'config_extension': {}, 'user_instruction': '/test-role hello', 'user_selection': '', - 'command_type': 'chat', - }) + } + context = make_ai_context({ **base, 'command_type': 'chat' }) actual_config = context['config'] actual_prompt = context['prompt'] assert 'model-common' == actual_config['options']['model'] - assert 'https://localhost/chat' == actual_config['options']['endpoint_url'] assert '0' == actual_config['ui']['paste_mode'] assert 'preset_tab' == actual_config['ui']['open_chat_command'] assert 'hello' == actual_prompt + assert 'https://localhost/chat' == actual_config['options']['endpoint_url'] - context = make_ai_context({ - 'config_default': default_config, - 'config_extension': {}, - 'user_instruction': '/test-role hello', - 'user_selection': '', - 'command_type': 'complete', - }) + context = make_ai_context({ **base, 'command_type': 'complete' }) actual_config = context['config'] actual_prompt = context['prompt'] assert 'model-common' == actual_config['options']['model'] + assert '0' == actual_config['ui']['paste_mode'] + assert 'hello' == actual_prompt assert 'https://localhost/complete' == actual_config['options']['endpoint_url'] + + context = make_ai_context({ **base, 'command_type': 'edit' }) + actual_config = context['config'] + actual_prompt = context['prompt'] + assert 'model-common' == actual_config['options']['model'] assert '0' == actual_config['ui']['paste_mode'] assert 'hello' == actual_prompt + assert 'https://localhost/edit' == actual_config['options']['endpoint_url'] def test_multiple_role_configs(): context = make_ai_context({ diff --git a/tests/resources/roles.ini b/tests/resources/roles.ini index c77d272..66b77ca 100644 --- a/tests/resources/roles.ini +++ b/tests/resources/roles.ini @@ -10,6 +10,8 @@ model = model-common endpoint_url = https://localhost/chat [test-role.options-complete] endpoint_url = https://localhost/complete +[test-role.options-edit] +endpoint_url = https://localhost/edit [test-role.ui] paste_mode = 0 [test-role.ui-chat] -- cgit v1.2.3