forked from Significant-Gravitas/AutoGPT
-
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.
Removing unitest in favor of pytest from test_config.py (Significant-…
…Gravitas#3417) * removing unitest in favor of pytest * remove singleton test and unnecessary fixture --------- Co-authored-by: James Collins <[email protected]>
- Loading branch information
Showing
1 changed file
with
115 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,126 +1,119 @@ | ||
from unittest import TestCase | ||
""" | ||
Test cases for the Config class, which handles the configuration settings | ||
for the AI and ensures it behaves as a singleton. | ||
""" | ||
|
||
import pytest | ||
|
||
from autogpt.config import Config | ||
|
||
|
||
class TestConfig(TestCase): | ||
""" | ||
Test cases for the Config class, which handles the configuration settings | ||
for the AI and ensures it behaves as a singleton. | ||
""" | ||
|
||
def setUp(self): | ||
""" | ||
Set up the test environment by creating an instance of the Config class. | ||
""" | ||
self.config = Config() | ||
|
||
def test_singleton(self): | ||
""" | ||
Test if the Config class behaves as a singleton by ensuring that two instances are the same. | ||
""" | ||
config2 = Config() | ||
self.assertIs(self.config, config2) | ||
|
||
def test_initial_values(self): | ||
""" | ||
Test if the initial values of the Config class attributes are set correctly. | ||
""" | ||
self.assertFalse(self.config.debug_mode) | ||
self.assertFalse(self.config.continuous_mode) | ||
self.assertFalse(self.config.speak_mode) | ||
self.assertEqual(self.config.fast_llm_model, "gpt-3.5-turbo") | ||
self.assertEqual(self.config.smart_llm_model, "gpt-4") | ||
self.assertEqual(self.config.fast_token_limit, 4000) | ||
self.assertEqual(self.config.smart_token_limit, 8000) | ||
|
||
def test_set_continuous_mode(self): | ||
""" | ||
Test if the set_continuous_mode() method updates the continuous_mode attribute. | ||
""" | ||
# Store continuous mode to reset it after the test | ||
continuous_mode = self.config.continuous_mode | ||
|
||
self.config.set_continuous_mode(True) | ||
self.assertTrue(self.config.continuous_mode) | ||
|
||
# Reset continuous mode | ||
self.config.set_continuous_mode(continuous_mode) | ||
|
||
def test_set_speak_mode(self): | ||
""" | ||
Test if the set_speak_mode() method updates the speak_mode attribute. | ||
""" | ||
# Store speak mode to reset it after the test | ||
speak_mode = self.config.speak_mode | ||
|
||
self.config.set_speak_mode(True) | ||
self.assertTrue(self.config.speak_mode) | ||
|
||
# Reset speak mode | ||
self.config.set_speak_mode(speak_mode) | ||
|
||
def test_set_fast_llm_model(self): | ||
""" | ||
Test if the set_fast_llm_model() method updates the fast_llm_model attribute. | ||
""" | ||
# Store model name to reset it after the test | ||
fast_llm_model = self.config.fast_llm_model | ||
|
||
self.config.set_fast_llm_model("gpt-3.5-turbo-test") | ||
self.assertEqual(self.config.fast_llm_model, "gpt-3.5-turbo-test") | ||
|
||
# Reset model name | ||
self.config.set_fast_llm_model(fast_llm_model) | ||
|
||
def test_set_smart_llm_model(self): | ||
""" | ||
Test if the set_smart_llm_model() method updates the smart_llm_model attribute. | ||
""" | ||
# Store model name to reset it after the test | ||
smart_llm_model = self.config.smart_llm_model | ||
|
||
self.config.set_smart_llm_model("gpt-4-test") | ||
self.assertEqual(self.config.smart_llm_model, "gpt-4-test") | ||
|
||
# Reset model name | ||
self.config.set_smart_llm_model(smart_llm_model) | ||
|
||
def test_set_fast_token_limit(self): | ||
""" | ||
Test if the set_fast_token_limit() method updates the fast_token_limit attribute. | ||
""" | ||
# Store token limit to reset it after the test | ||
fast_token_limit = self.config.fast_token_limit | ||
|
||
self.config.set_fast_token_limit(5000) | ||
self.assertEqual(self.config.fast_token_limit, 5000) | ||
|
||
# Reset token limit | ||
self.config.set_fast_token_limit(fast_token_limit) | ||
|
||
def test_set_smart_token_limit(self): | ||
""" | ||
Test if the set_smart_token_limit() method updates the smart_token_limit attribute. | ||
""" | ||
# Store token limit to reset it after the test | ||
smart_token_limit = self.config.smart_token_limit | ||
|
||
self.config.set_smart_token_limit(9000) | ||
self.assertEqual(self.config.smart_token_limit, 9000) | ||
|
||
# Reset token limit | ||
self.config.set_smart_token_limit(smart_token_limit) | ||
|
||
def test_set_debug_mode(self): | ||
""" | ||
Test if the set_debug_mode() method updates the debug_mode attribute. | ||
""" | ||
# Store debug mode to reset it after the test | ||
debug_mode = self.config.debug_mode | ||
|
||
self.config.set_debug_mode(True) | ||
self.assertTrue(self.config.debug_mode) | ||
|
||
# Reset debug mode | ||
self.config.set_debug_mode(debug_mode) | ||
def test_initial_values(config): | ||
""" | ||
Test if the initial values of the Config class attributes are set correctly. | ||
""" | ||
assert config.debug_mode == False | ||
assert config.continuous_mode == False | ||
assert config.speak_mode == False | ||
assert config.fast_llm_model == "gpt-3.5-turbo" | ||
assert config.smart_llm_model == "gpt-4" | ||
assert config.fast_token_limit == 4000 | ||
assert config.smart_token_limit == 8000 | ||
|
||
|
||
def test_set_continuous_mode(config): | ||
""" | ||
Test if the set_continuous_mode() method updates the continuous_mode attribute. | ||
""" | ||
# Store continuous mode to reset it after the test | ||
continuous_mode = config.continuous_mode | ||
|
||
config.set_continuous_mode(True) | ||
assert config.continuous_mode == True | ||
|
||
# Reset continuous mode | ||
config.set_continuous_mode(continuous_mode) | ||
|
||
|
||
def test_set_speak_mode(config): | ||
""" | ||
Test if the set_speak_mode() method updates the speak_mode attribute. | ||
""" | ||
# Store speak mode to reset it after the test | ||
speak_mode = config.speak_mode | ||
|
||
config.set_speak_mode(True) | ||
assert config.speak_mode == True | ||
|
||
# Reset speak mode | ||
config.set_speak_mode(speak_mode) | ||
|
||
|
||
def test_set_fast_llm_model(config): | ||
""" | ||
Test if the set_fast_llm_model() method updates the fast_llm_model attribute. | ||
""" | ||
# Store model name to reset it after the test | ||
fast_llm_model = config.fast_llm_model | ||
|
||
config.set_fast_llm_model("gpt-3.5-turbo-test") | ||
assert config.fast_llm_model == "gpt-3.5-turbo-test" | ||
|
||
# Reset model name | ||
config.set_fast_llm_model(fast_llm_model) | ||
|
||
|
||
def test_set_smart_llm_model(config): | ||
""" | ||
Test if the set_smart_llm_model() method updates the smart_llm_model attribute. | ||
""" | ||
# Store model name to reset it after the test | ||
smart_llm_model = config.smart_llm_model | ||
|
||
config.set_smart_llm_model("gpt-4-test") | ||
assert config.smart_llm_model == "gpt-4-test" | ||
|
||
# Reset model name | ||
config.set_smart_llm_model(smart_llm_model) | ||
|
||
|
||
def test_set_fast_token_limit(config): | ||
""" | ||
Test if the set_fast_token_limit() method updates the fast_token_limit attribute. | ||
""" | ||
# Store token limit to reset it after the test | ||
fast_token_limit = config.fast_token_limit | ||
|
||
config.set_fast_token_limit(5000) | ||
assert config.fast_token_limit == 5000 | ||
|
||
# Reset token limit | ||
config.set_fast_token_limit(fast_token_limit) | ||
|
||
|
||
def test_set_smart_token_limit(config): | ||
""" | ||
Test if the set_smart_token_limit() method updates the smart_token_limit attribute. | ||
""" | ||
# Store token limit to reset it after the test | ||
smart_token_limit = config.smart_token_limit | ||
|
||
config.set_smart_token_limit(9000) | ||
assert config.smart_token_limit == 9000 | ||
|
||
# Reset token limit | ||
config.set_smart_token_limit(smart_token_limit) | ||
|
||
|
||
def test_set_debug_mode(config): | ||
""" | ||
Test if the set_debug_mode() method updates the debug_mode attribute. | ||
""" | ||
# Store debug mode to reset it after the test | ||
debug_mode = config.debug_mode | ||
|
||
config.set_debug_mode(True) | ||
assert config.debug_mode == True | ||
|
||
# Reset debug mode | ||
config.set_debug_mode(debug_mode) |