mirror of
https://github.com/evennia/evennia.git
synced 2026-03-31 04:57:16 +02:00
Make erroring LLM unit test more stringent
This commit is contained in:
parent
a56852d38d
commit
ca35b323ae
1 changed files with 13 additions and 5 deletions
|
|
@ -13,17 +13,25 @@ from .llm_npc import LLMNPC
|
|||
|
||||
|
||||
class TestLLMClient(BaseEvenniaTestCase):
|
||||
@override_settings(LLM_PROMPT_PREFIX="You are a test bot.", TEST_ENVIRONMENT=True)
|
||||
@override_settings(LLM_PROMPT_PREFIX="You are a test bot.")
|
||||
@patch("evennia.contrib.rpg.llm.llm_npc.task.deferLater")
|
||||
def setUp(self):
|
||||
self.npc = create_object(LLMNPC, key="Test NPC")
|
||||
self.npc.db_home = None # fix a bug in test suite
|
||||
self.npc.save()
|
||||
|
||||
def tearDown(self):
|
||||
self.npc.delete()
|
||||
super().tearDown()
|
||||
|
||||
def test_npc_at_talked_to(self, mock_deferLater):
|
||||
"""
|
||||
Test the LLMNPC class.
|
||||
"""
|
||||
npc = create_object(LLMNPC, key="Test NPC")
|
||||
mock_LLMClient = Mock()
|
||||
npc.ndb.llm_client = mock_LLMClient
|
||||
self.npc.ndb.llm_client = mock_LLMClient
|
||||
|
||||
npc.at_talked_to("Hello", npc)
|
||||
self.npc.at_talked_to("Hello", self.npc)
|
||||
|
||||
mock_deferLater.assert_called_with(Something, npc.thinking_timeout, Something)
|
||||
mock_deferLater.assert_called_with(Something, self.npc.thinking_timeout, Something)
|
||||
mock_LLMClient.get_response.assert_called_with("You are a test bot.\nTest NPC: Hello")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue