Fix history limit handling.

This commit is contained in:
OK
2023-04-13 18:36:06 +02:00
parent 79e95ab06c
commit 2508a12b44
4 changed files with 24 additions and 19 deletions
+4 -4
View File
@@ -162,13 +162,13 @@ class TestFunctionality(TestBotBase):
@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.bot.airesponder.update_history({'content': '{"q": "What\'s your name?"}'}, {'content': '{"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.bot.airesponder.update_history({'content': '{"q1": "Q1"}'}, {'content': '{"a1": "A1"}'}, 2)
self.bot.airesponder.update_history({'content': '{"q2": "Q2"}'}, {'content': '{"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)
self.bot.airesponder.update_history({'content': '{"q": "What\'s your favorite color?"}'}, {'content': '{"a": "Blue"}'}, 10)
mock_file.assert_called_once_with("mock_file.pkl", "wb")
mock_file().write.assert_called_once()