2021-10-03 05:28:33 +02:00
|
|
|
# Internal Packages
|
|
|
|
from src.main import model
|
|
|
|
from src.search_type import asymmetric
|
2022-01-15 02:13:14 +01:00
|
|
|
from src.utils.rawconfig import ContentTypeConfig, SearchTypeConfig
|
2021-10-03 05:28:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Test
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
2022-01-15 02:13:14 +01:00
|
|
|
def test_asymmetric_setup(content_config: ContentTypeConfig, search_config: SearchTypeConfig):
|
2021-10-03 05:28:33 +02:00
|
|
|
# Act
|
|
|
|
# Regenerate notes embeddings during asymmetric setup
|
2022-01-15 02:13:14 +01:00
|
|
|
notes_model = asymmetric.setup(content_config.org, search_config.asymmetric, regenerate=True)
|
2021-10-03 05:28:33 +02:00
|
|
|
|
|
|
|
# Assert
|
|
|
|
assert len(notes_model.entries) == 10
|
|
|
|
assert len(notes_model.corpus_embeddings) == 10
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
2022-01-15 02:13:14 +01:00
|
|
|
def test_asymmetric_search(content_config: ContentTypeConfig, search_config: SearchTypeConfig):
|
2021-10-03 05:28:33 +02:00
|
|
|
# Arrange
|
2022-01-15 02:13:14 +01:00
|
|
|
model.notes_search = asymmetric.setup(content_config.org, search_config.asymmetric, regenerate=False)
|
2021-10-03 05:28:33 +02:00
|
|
|
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
|