mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-08 06:40:39 +08:00
Support context aware settings (for each incoming request), support override of settings, refactor CLI to use pr_agent.py
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
import logging
|
||||
|
||||
from pr_agent.algo.git_patch_processing import handle_patch_deletions
|
||||
from pr_agent.config_loader import settings
|
||||
from pr_agent.config_loader import get_settings
|
||||
|
||||
"""
|
||||
Code Analysis
|
||||
@ -49,7 +49,7 @@ class TestHandlePatchDeletions:
|
||||
original_file_content_str = 'foo\nbar\n'
|
||||
new_file_content_str = ''
|
||||
file_name = 'file.py'
|
||||
settings.config.verbosity_level = 1
|
||||
get_settings().config.verbosity_level = 1
|
||||
|
||||
with caplog.at_level(logging.INFO):
|
||||
handle_patch_deletions(patch, original_file_content_str, new_file_content_str, file_name)
|
||||
|
@ -1,50 +0,0 @@
|
||||
|
||||
# Generated by CodiumAI
|
||||
from pr_agent.algo.utils import update_settings_from_args
|
||||
import logging
|
||||
from pr_agent.config_loader import settings
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
class TestUpdateSettingsFromArgs:
|
||||
# Tests that the function updates the setting when passed a single valid argument.
|
||||
def test_single_valid_argument(self):
|
||||
args = ['--pr_code_suggestions.extra_instructions="be funny"']
|
||||
update_settings_from_args(args)
|
||||
assert settings.pr_code_suggestions.extra_instructions == '"be funny"'
|
||||
|
||||
# Tests that the function updates the settings when passed multiple valid arguments.
|
||||
def test_multiple_valid_arguments(self):
|
||||
args = ['--pr_code_suggestions.extra_instructions="be funny"', '--pr_code_suggestions.num_code_suggestions=3']
|
||||
update_settings_from_args(args)
|
||||
assert settings.pr_code_suggestions.extra_instructions == '"be funny"'
|
||||
assert settings.pr_code_suggestions.num_code_suggestions == 3
|
||||
|
||||
# Tests that the function updates the setting when passed a boolean value.
|
||||
def test_boolean_values(self):
|
||||
settings.pr_code_suggestions.enabled = False
|
||||
args = ['--pr_code_suggestions.enabled=true']
|
||||
update_settings_from_args(args)
|
||||
assert 'pr_code_suggestions' in settings
|
||||
assert 'enabled' in settings.pr_code_suggestions
|
||||
assert settings.pr_code_suggestions.enabled == True
|
||||
|
||||
# Tests that the function updates the setting when passed an integer value.
|
||||
def test_integer_values(self):
|
||||
args = ['--pr_code_suggestions.num_code_suggestions=3']
|
||||
update_settings_from_args(args)
|
||||
assert settings.pr_code_suggestions.num_code_suggestions == 3
|
||||
|
||||
# Tests that the function does not update any settings when passed an empty argument list.
|
||||
def test_empty_argument_list(self):
|
||||
args = []
|
||||
update_settings_from_args(args)
|
||||
assert settings == settings
|
||||
|
||||
# Tests that the function logs an error when passed an invalid argument format.
|
||||
def test_invalid_argument_format(self, caplog):
|
||||
args = ['--pr_code_suggestions.extra_instructions="be funny"', '--pr_code_suggestions.num_code_suggestions']
|
||||
with caplog.at_level(logging.ERROR):
|
||||
update_settings_from_args(args)
|
||||
assert 'Invalid argument format' in caplog.text
|
Reference in New Issue
Block a user