configuration: made 'default' AI ID optional
This commit is contained in:
@@ -59,7 +59,7 @@ class TestConfig(unittest.TestCase):
|
||||
source_dict = {
|
||||
'db': './test_db/',
|
||||
'ais': {
|
||||
'default': {
|
||||
'myopenai': {
|
||||
'name': 'openai',
|
||||
'system': 'Custom system',
|
||||
'api_key': '9876543210',
|
||||
@@ -75,10 +75,10 @@ class TestConfig(unittest.TestCase):
|
||||
config = Config.from_dict(source_dict)
|
||||
self.assertEqual(config.db, './test_db/')
|
||||
self.assertEqual(len(config.ais), 1)
|
||||
self.assertEqual(config.ais['default'].name, 'openai')
|
||||
self.assertEqual(cast(OpenAIConfig, config.ais['default']).system, 'Custom system')
|
||||
self.assertEqual(config.ais['myopenai'].name, 'openai')
|
||||
self.assertEqual(cast(OpenAIConfig, config.ais['myopenai']).system, 'Custom system')
|
||||
# check that 'ID' has been added
|
||||
self.assertEqual(config.ais['default'].ID, 'default')
|
||||
self.assertEqual(config.ais['myopenai'].ID, 'myopenai')
|
||||
|
||||
def test_create_default_should_create_default_config(self) -> None:
|
||||
Config.create_default(Path(self.test_file.name))
|
||||
@@ -117,8 +117,8 @@ class TestConfig(unittest.TestCase):
|
||||
config = Config(
|
||||
db='./test_db/',
|
||||
ais={
|
||||
'default': OpenAIConfig(
|
||||
ID='default',
|
||||
'myopenai': OpenAIConfig(
|
||||
ID='myopenai',
|
||||
system='Custom system',
|
||||
api_key='9876543210',
|
||||
model='custom_model',
|
||||
@@ -135,7 +135,7 @@ class TestConfig(unittest.TestCase):
|
||||
saved_config = yaml.load(f, Loader=yaml.FullLoader)
|
||||
self.assertEqual(saved_config['db'], './test_db/')
|
||||
self.assertEqual(len(saved_config['ais']), 1)
|
||||
self.assertEqual(saved_config['ais']['default']['system'], 'Custom system')
|
||||
self.assertEqual(saved_config['ais']['myopenai']['system'], 'Custom system')
|
||||
|
||||
def test_from_file_error_unknown_ai(self) -> None:
|
||||
source_dict = {
|
||||
|
||||
Reference in New Issue
Block a user