MCPcopy Create free account
hub / github.com/SkyworkAI/DeepResearchAgent / test_basic_document_operations

Method test_basic_document_operations

tests/test_faiss.py:74–118  ·  view source on GitHub ↗

Test basic document add/delete operations.

(self)

Source from the content-addressed store, hash-verified

72 self.failed_tests += 1
73
74 async def test_basic_document_operations(self):
75 """Test basic document add/delete operations."""
76 print("\n=== Testing Basic Document Operations ===")
77
78 # Test add single document
79 texts = ["This is a test document about machine learning and AI."]
80 metadatas = [{"category": "AI", "author": "test_user"}]
81
82 request = FaissAddRequest(texts=texts, metadatas=metadatas)
83 result = await self.faiss_service.add_documents(request)
84
85 self.assert_test(result.count == 1,
86 "Add single document",
87 f"Expected count=1, got count={result.count}")
88
89 if result.ids:
90 self.test_document_ids.extend(result.ids)
91
92 # Test add multiple documents
93 texts = [
94 "Python is a great programming language for data science.",
95 "Machine learning algorithms can learn from data patterns.",
96 "Deep learning uses neural networks with multiple layers."
97 ]
98 metadatas = [
99 {"category": "Programming", "topic": "Python"},
100 {"category": "AI", "topic": "ML"},
101 {"category": "AI", "topic": "Deep Learning"}
102 ]
103
104 request = FaissAddRequest(texts=texts, metadatas=metadatas)
105 result = await self.faiss_service.add_documents(request)
106
107 self.assert_test(result.count == 3,
108 "Add multiple documents",
109 f"Expected count=3, got count={result.count}")
110
111 if result.ids:
112 self.test_document_ids.extend(result.ids)
113
114 # Test get index info
115 index_info = await self.faiss_service.get_index_info()
116 self.assert_test(index_info.total_documents >= 4,
117 "Get index info",
118 f"Expected >=4 documents, got {index_info.total_documents}")
119
120 async def test_search_functionality(self):
121 """Test search functionality."""

Callers 1

run_all_testsMethod · 0.95

Calls 6

assert_testMethod · 0.95
FaissAddRequestClass · 0.90
printFunction · 0.85
add_documentsMethod · 0.45
extendMethod · 0.45
get_index_infoMethod · 0.45

Tested by

no test coverage detected