Fix history limit handling.
This commit is contained in:
+4
-4
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user