Add history test.
This commit is contained in:
parent
24ae6bcf32
commit
96fe10f2e4
@ -148,6 +148,18 @@ class TestFunctionality(TestBotBase):
|
|||||||
with pytest.raises(RuntimeError, match="Failed to generate answer after multiple retries"):
|
with pytest.raises(RuntimeError, match="Failed to generate answer after multiple retries"):
|
||||||
await self.bot.on_message(message)
|
await self.bot.on_message(message)
|
||||||
|
|
||||||
|
@patch("builtins.open", new_callable=mock_open)
|
||||||
|
def test_update_history_with_file(self, mock_file):
|
||||||
|
self.bot.airesponder.update_history({"q": "What's your name?"}, {"a": "AI"}, 10)
|
||||||
|
self.assertEqual(len(self.bot.airesponder.history), 2)
|
||||||
|
self.bot.airesponder.update_history({"q1": "Q1"}, {"a1": "A1"}, 2)
|
||||||
|
self.bot.airesponder.update_history({"q2": "Q2"}, {"a2": "A2"}, 2)
|
||||||
|
self.assertEqual(len(self.bot.airesponder.history), 2)
|
||||||
|
self.bot.airesponder.history_file = "mock_file.pkl"
|
||||||
|
self.bot.airesponder.update_history({"q": "What's your favorite color?"}, {"a": "Blue"}, 10)
|
||||||
|
mock_file.assert_called_once_with("mock_file.pkl", "wb")
|
||||||
|
mock_file().write.assert_called_once()
|
||||||
|
|
||||||
async def test_on_message_event4(self) -> None:
|
async def test_on_message_event4(self) -> None:
|
||||||
async def acreate(*a, **kw):
|
async def acreate(*a, **kw):
|
||||||
answer = {'answer': 'Hello!',
|
answer = {'answer': 'Hello!',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user