Skip to content

Commit

Permalink
feat: Updated backend/tests/test_memory_manager.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Dec 29, 2023
1 parent b11cd11 commit 459d4cf
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions backend/tests/test_memory_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ def setUp(self):
self.cursor.fetchall.return_value = [("test_context",)]
self.memory_manager = MemoryManager(db_connection=self.conn)

def test_summarize_context_shortens_long_context(self):
# Arrange: Create a context longer than what summarize would return
long_context = 'A very long repetitive context ' * 30 # assuming summarization would shorten this
self.memory_manager.working_context.context = long_context
# Act: Call summarize_context method
summary = self.memory_manager.working_context.summarize_context()
# Assert: Check that the summary is shorter than the original context
assert len(summary) < len(long_context), 'Summarize did not shorten the context'

def test_turn_counter_reset_after_5th_update(self):
# Arrange: Reset the turn counter to 0
self.memory_manager.working_context.turn_counter = 0
# Act: Call the update_context method 5 times
for _ in range(5):
asyncio.run(self.memory_manager.update_context())
# Assert: Check whether the turn_counter is reset to 0
assert self.memory_manager.working_context.turn_counter == 0, 'Turn counter was not reset after 5th update'

def test_add_message(self):
# Arrange: Prepare the message to be added
role = "user"
Expand Down

0 comments on commit 459d4cf

Please sign in to comment.