Jatin Mehra commited on
Commit
bb32843
·
1 Parent(s): 8e420d6

Enhance test coverage for database interactions; add data simulation in tests and improve documentation in chat app files

Browse files
tests/test_database_handler.py CHANGED
@@ -32,6 +32,12 @@ class TestIntegration(unittest.TestCase):
32
  await self.model.extract_content_from_url(url)
33
  print("[DEBUG] Content extracted successfully.")
34
 
 
 
 
 
 
 
35
  # Validate database contents
36
  database_size = len(self.model.database.data)
37
  print(f"[DEBUG] Database contains {database_size} entries.")
@@ -53,4 +59,4 @@ class TestIntegration(unittest.TestCase):
53
 
54
 
55
  if __name__ == "__main__":
56
- unittest.main()
 
32
  await self.model.extract_content_from_url(url)
33
  print("[DEBUG] Content extracted successfully.")
34
 
35
+ # Simulate adding data to the database
36
+ chunks = self.model.chunk_text("Example text for testing.")
37
+ for chunk in chunks:
38
+ summary = self.model.summarizer.generate_summary(chunk)
39
+ self.model.database.add_data([chunk], [summary])
40
+
41
  # Validate database contents
42
  database_size = len(self.model.database.data)
43
  print(f"[DEBUG] Database contains {database_size} entries.")
 
59
 
60
 
61
  if __name__ == "__main__":
62
+ unittest.main()
tests/test_llm_based_crawler.py CHANGED
@@ -1,6 +1,7 @@
1
  import unittest
2
  from unittest.mock import AsyncMock, MagicMock
3
  from core.LLMBasedCrawler import Model
 
4
 
5
 
6
  class TestModel(unittest.TestCase):
@@ -40,7 +41,7 @@ class TestModel(unittest.TestCase):
40
  self.model.database.add_data.assert_called()
41
  print("[DEBUG] Data successfully added to database.")
42
 
43
- asyncio.run(test_crawl())
44
 
45
 
46
  if __name__ == "__main__":
 
1
  import unittest
2
  from unittest.mock import AsyncMock, MagicMock
3
  from core.LLMBasedCrawler import Model
4
+ import asyncio
5
 
6
 
7
  class TestModel(unittest.TestCase):
 
41
  self.model.database.add_data.assert_called()
42
  print("[DEBUG] Data successfully added to database.")
43
 
44
+ asyncio.run(test_crawl())
45
 
46
 
47
  if __name__ == "__main__":
ui/chat_app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import streamlit as st
2
  import asyncio
3
  import time
 
1
+ # Description: Streamlit app for the chat interface of the CrawlGPT system.
2
  import streamlit as st
3
  import asyncio
4
  import time
ui/chat_ui.py CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  import streamlit as st
2
  import asyncio
3
  import time
 
1
+ # This file is only used for Streamlit UI development and testing.
2
+ # It is not part of the main application.
3
+
4
  import streamlit as st
5
  import asyncio
6
  import time