|
1 |
| -import unittest |
| 1 | +from unittest import TestCase |
2 | 2 |
|
3 | 3 | from autogpt.config import Config
|
4 | 4 |
|
5 | 5 |
|
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 | + |
7 | 18 | 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 | + """ |
9 | 22 | config2 = Config()
|
10 |
| - self.assertIs(config1, config2) |
| 23 | + self.assertIs(self.config, config2) |
11 | 24 |
|
12 | 25 | 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) |
21 | 36 |
|
22 | 37 | 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) |
26 | 43 |
|
27 | 44 | 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) |
31 | 50 |
|
32 | 51 | 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") |
36 | 57 |
|
37 | 58 | 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") |
41 | 64 |
|
42 | 65 | 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) |
46 | 71 |
|
47 | 72 | 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) |
51 | 78 |
|
52 | 79 | 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