forked from devchat-ai/devchat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new unit tests for the 'ConfigManager' class
- In tests, used tmp_path directly instead of converting it to a string. - Used the built-in 'exclude_none' option in the 'dict' method.
- Loading branch information
1 parent
db2c472
commit 61c0c91
Showing
6 changed files
with
44 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
from devchat.config import ConfigManager, ModelConfig, ChatConfig, OpenAIChatParameters | ||
|
||
|
||
def test_create_sample_config(tmp_path): | ||
ConfigManager(tmp_path) | ||
assert os.path.exists(os.path.join(tmp_path, 'config.yml')) | ||
|
||
|
||
def test_load_and_validate_config(tmp_path): | ||
config_manager = ConfigManager(tmp_path) | ||
assert isinstance(config_manager.config, ChatConfig) | ||
|
||
|
||
def test_get_model_config(tmp_path): | ||
config_manager = ConfigManager(tmp_path) | ||
model_config = config_manager.get_model_config('gpt-4') | ||
assert model_config.id == 'gpt-4' | ||
assert model_config.max_input_tokens == 6000 | ||
assert model_config.parameters.temperature == 0 | ||
assert model_config.parameters.stream is True | ||
|
||
|
||
def test_update_model_config(tmp_path): | ||
config_manager = ConfigManager(tmp_path) | ||
new_model_config = ModelConfig( | ||
id='gpt-4', | ||
max_input_tokens=7000, | ||
parameters=OpenAIChatParameters(temperature=0.5) | ||
) | ||
updated_model_config = config_manager.update_model_config(new_model_config) | ||
assert updated_model_config.max_input_tokens == 7000 | ||
assert updated_model_config.parameters.temperature == 0.5 | ||
assert updated_model_config.parameters.stream is True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters