Skip to content

Commit 110e2f3

Browse files
committed
Adjust test_config file
1 parent 793ea4d commit 110e2f3

File tree

1 file changed

+62
-37
lines changed

1 file changed

+62
-37
lines changed

tests/test_config.py

+62-37
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,84 @@
1-
import unittest
1+
from unittest import TestCase
22

33
from autogpt.config import Config
44

55

6-
class TestConfig(unittest.TestCase):
6+
class TestConfig(TestCase):
7+
"""
8+
Test cases for the Config class, which handles the configuration settings
9+
for the AI and ensures it behaves as a singleton.
10+
"""
11+
12+
def setUp(self):
13+
"""
14+
Set up the test environment by creating an instance of the Config class.
15+
"""
16+
self.config = Config()
17+
718
def test_singleton(self):
8-
config1 = Config()
19+
"""
20+
Test if the Config class behaves as a singleton by ensuring that two instances are the same.
21+
"""
922
config2 = Config()
10-
self.assertIs(config1, config2)
23+
self.assertIs(self.config, config2)
1124

1225
def test_initial_values(self):
13-
config = Config()
14-
self.assertFalse(config.debug_mode)
15-
self.assertFalse(config.continuous_mode)
16-
self.assertFalse(config.speak_mode)
17-
self.assertEqual(config.fast_llm_model, "gpt-3.5-turbo")
18-
self.assertEqual(config.smart_llm_model, "gpt-4")
19-
self.assertEqual(config.fast_token_limit, 4000)
20-
self.assertEqual(config.smart_token_limit, 8000)
26+
"""
27+
Test if the initial values of the Config class attributes are set correctly.
28+
"""
29+
self.assertFalse(self.config.debug_mode)
30+
self.assertFalse(self.config.continuous_mode)
31+
self.assertFalse(self.config.speak_mode)
32+
self.assertEqual(self.config.fast_llm_model, "gpt-3.5-turbo")
33+
self.assertEqual(self.config.smart_llm_model, "gpt-4")
34+
self.assertEqual(self.config.fast_token_limit, 4000)
35+
self.assertEqual(self.config.smart_token_limit, 8000)
2136

2237
def test_set_continuous_mode(self):
23-
config = Config()
24-
config.set_continuous_mode(True)
25-
self.assertTrue(config.continuous_mode)
38+
"""
39+
Test if the set_continuous_mode() method updates the continuous_mode attribute.
40+
"""
41+
self.config.set_continuous_mode(True)
42+
self.assertTrue(self.config.continuous_mode)
2643

2744
def test_set_speak_mode(self):
28-
config = Config()
29-
config.set_speak_mode(True)
30-
self.assertTrue(config.speak_mode)
45+
"""
46+
Test if the set_speak_mode() method updates the speak_mode attribute.
47+
"""
48+
self.config.set_speak_mode(True)
49+
self.assertTrue(self.config.speak_mode)
3150

3251
def test_set_fast_llm_model(self):
33-
config = Config()
34-
config.set_fast_llm_model("gpt-3.5-turbo-test")
35-
self.assertEqual(config.fast_llm_model, "gpt-3.5-turbo-test")
52+
"""
53+
Test if the set_fast_llm_model() method updates the fast_llm_model attribute.
54+
"""
55+
self.config.set_fast_llm_model("gpt-3.5-turbo-test")
56+
self.assertEqual(self.config.fast_llm_model, "gpt-3.5-turbo-test")
3657

3758
def test_set_smart_llm_model(self):
38-
config = Config()
39-
config.set_smart_llm_model("gpt-4-test")
40-
self.assertEqual(config.smart_llm_model, "gpt-4-test")
59+
"""
60+
Test if the set_smart_llm_model() method updates the smart_llm_model attribute.
61+
"""
62+
self.config.set_smart_llm_model("gpt-4-test")
63+
self.assertEqual(self.config.smart_llm_model, "gpt-4-test")
4164

4265
def test_set_fast_token_limit(self):
43-
config = Config()
44-
config.set_fast_token_limit(5000)
45-
self.assertEqual(config.fast_token_limit, 5000)
66+
"""
67+
Test if the set_fast_token_limit() method updates the fast_token_limit attribute.
68+
"""
69+
self.config.set_fast_token_limit(5000)
70+
self.assertEqual(self.config.fast_token_limit, 5000)
4671

4772
def test_set_smart_token_limit(self):
48-
config = Config()
49-
config.set_smart_token_limit(9000)
50-
self.assertEqual(config.smart_token_limit, 9000)
73+
"""
74+
Test if the set_smart_token_limit() method updates the smart_token_limit attribute.
75+
"""
76+
self.config.set_smart_token_limit(9000)
77+
self.assertEqual(self.config.smart_token_limit, 9000)
5178

5279
def test_set_debug_mode(self):
53-
config = Config()
54-
config.set_debug_mode(True)
55-
self.assertTrue(config.debug_mode)
56-
57-
58-
if __name__ == "__main__":
59-
unittest.main()
80+
"""
81+
Test if the set_debug_mode() method updates the debug_mode attribute.
82+
"""
83+
self.config.set_debug_mode(True)
84+
self.assertTrue(self.config.debug_mode)

0 commit comments

Comments
 (0)