# 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