mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-25 08:04:19 +03:00
652d2b32e2
selection now fixed # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from unittest.mock import Mock
|
|
from uuid import UUID
|
|
|
|
from modules.brain.entity.brain_entity import BrainEntity
|
|
from modules.brain.service.brain_service import BrainService
|
|
|
|
|
|
def test_find_brain_from_question_with_history_and_brain_id():
|
|
brain_service = BrainService()
|
|
user = Mock()
|
|
user.id = 1
|
|
chat_id = UUID("12345678123456781234567812345678")
|
|
question = "What is the meaning of life?"
|
|
brain_id = UUID("87654321876543218765432187654321")
|
|
history = [
|
|
{
|
|
"user_message": "What is AI?",
|
|
"brain_id": UUID("87654321876543218765432187654321"),
|
|
}
|
|
]
|
|
vector_store = Mock()
|
|
vector_store.find_brain_closest_query.return_value = []
|
|
|
|
brain_entity_mock = Mock(spec=BrainEntity) # Create a mock BrainEntity
|
|
brain_service.get_brain_by_id = Mock(
|
|
return_value=brain_entity_mock
|
|
) # Mock the get_brain_by_id method
|
|
|
|
brain_to_use, metadata = brain_service.find_brain_from_question(
|
|
brain_id, question, user, chat_id, history, vector_store
|
|
)
|
|
|
|
assert isinstance(brain_to_use, BrainEntity)
|
|
assert "close_brains" in metadata
|