-
Notifications
You must be signed in to change notification settings - Fork 44.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Nonetype error from command_name.startswith() (#5079)
Co-authored-by: lc0rp <2609411+lc0rp@users.noreply.github.com> Co-authored-by: James Collins <collijk@uw.edu>
- Loading branch information
1 parent
3651d22
commit ad18f77
Showing
2 changed files
with
51 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from unittest.mock import MagicMock, patch | ||
|
||
from colorama import Fore | ||
|
||
from autogpt.app.main import update_user | ||
|
||
|
||
def test_update_user_command_name_is_none() -> None: | ||
# Mock necessary objects | ||
config = MagicMock() | ||
ai_config = MagicMock() | ||
assistant_reply_dict = MagicMock() | ||
|
||
# Mock print_assistant_thoughts and logger.typewriter_log | ||
with patch( | ||
"autogpt.app.main.print_assistant_thoughts" | ||
) as mock_print_assistant_thoughts, patch( | ||
"autogpt.app.main.logger.typewriter_log" | ||
) as mock_logger_typewriter_log: | ||
# Test the update_user function with None command_name | ||
update_user(config, ai_config, None, None, assistant_reply_dict) | ||
|
||
# Check that print_assistant_thoughts was called once | ||
mock_print_assistant_thoughts.assert_called_once_with( | ||
ai_config.ai_name, assistant_reply_dict, config | ||
) | ||
|
||
# Check that logger.typewriter_log was called once with expected arguments | ||
mock_logger_typewriter_log.assert_called_once_with( | ||
"NO ACTION SELECTED: ", | ||
Fore.RED, | ||
f"The Agent failed to select an action.", | ||
) |