mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Split test_main into client and search type specific test files
- Move search config fixture to conftests.py to be shared across tests - Move image search type specific tests to test_image_search.py file - Move, create asymmetric search type specific tests in new file
This commit is contained in:
37
tests/test_asymmetric_search.py
Normal file
37
tests/test_asymmetric_search.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# Internal Packages
|
||||
from src.main import model
|
||||
from src.search_type import asymmetric
|
||||
|
||||
|
||||
# Test
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
def test_asymmetric_setup(search_config):
|
||||
# Act
|
||||
# Regenerate notes embeddings during asymmetric setup
|
||||
notes_model = asymmetric.setup(search_config.notes, regenerate=True)
|
||||
|
||||
# Assert
|
||||
assert len(notes_model.entries) == 10
|
||||
assert len(notes_model.corpus_embeddings) == 10
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
def test_asymmetric_search(search_config):
|
||||
# Arrange
|
||||
model.notes_search = asymmetric.setup(search_config.notes, regenerate=False)
|
||||
query = "How to git install application?"
|
||||
|
||||
# Act
|
||||
hits = asymmetric.query(
|
||||
query,
|
||||
model = model.notes_search)
|
||||
|
||||
results = asymmetric.collate_results(
|
||||
hits,
|
||||
model.notes_search.entries,
|
||||
count=1)
|
||||
|
||||
# Assert
|
||||
# Actual_data should contain "Semantic Search via Emacs" entry
|
||||
search_result = results[0]["Entry"]
|
||||
assert "git clone" in search_result
|
||||
Reference in New Issue
Block a user