Skip to content

Commit

Permalink
Update memory_tests.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AndresCdo committed Apr 20, 2023
1 parent fa07d56 commit 8e78c18
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/integration/memory_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@


class TestLocalCache(unittest.TestCase):
"""Tests for LocalCache class"""
def random_string(self, length):
"""Generate a random string of fixed length"""
return "".join(random.choice(string.ascii_letters) for _ in range(length))

def setUp(self):
"""Set up the test environment"""
cfg = cfg = Config()
self.cache = LocalCache(cfg)
self.cache.clear()
Expand All @@ -24,7 +27,7 @@ def setUp(self):
"The cake is a lie, but the pie is always true",
"ChatGPT is an advanced AI model for conversation",
]

# Add the example texts to the cache
for text in self.example_texts:
self.cache.add(text)

Expand All @@ -33,6 +36,7 @@ def setUp(self):
self.cache.add(self.random_string(10))

def test_get_relevant(self):
"""Test getting relevant texts from the cache"""
query = "I'm interested in artificial intelligence and NLP"
k = 3
relevant_texts = self.cache.get_relevant(query, k)
Expand Down

0 comments on commit 8e78c18

Please sign in to comment.