Mel Seto
commited on
Commit
·
3d5b80d
1
Parent(s):
6be9392
remove test_retriever.py
Browse files- tests/test_retriever.py +0 -39
tests/test_retriever.py
DELETED
|
@@ -1,39 +0,0 @@
|
|
| 1 |
-
import pytest
|
| 2 |
-
from retrieval.retriever import retrieve_idiom
|
| 3 |
-
|
| 4 |
-
def test_basic_retrieval():
|
| 5 |
-
situation = "I want to describe something that never changes."
|
| 6 |
-
top_k = 3
|
| 7 |
-
results = retrieve_idiom(situation, top_k=top_k)
|
| 8 |
-
|
| 9 |
-
# Check type and length
|
| 10 |
-
assert isinstance(results, list)
|
| 11 |
-
assert len(results) == top_k
|
| 12 |
-
|
| 13 |
-
# Check that each entry is a string
|
| 14 |
-
for item in results:
|
| 15 |
-
assert isinstance(item, str)
|
| 16 |
-
assert len(item) > 0
|
| 17 |
-
|
| 18 |
-
def test_empty_query():
|
| 19 |
-
results = retrieve_idiom("", top_k=2)
|
| 20 |
-
assert isinstance(results, list)
|
| 21 |
-
assert len(results) == 2
|
| 22 |
-
for item in results:
|
| 23 |
-
assert isinstance(item, str)
|
| 24 |
-
assert len(item) > 0
|
| 25 |
-
|
| 26 |
-
## TODO: fix embedding logic so that this test passes
|
| 27 |
-
@pytest.mark.parametrize(
|
| 28 |
-
"situation, idiom",
|
| 29 |
-
[
|
| 30 |
-
("to return from a rewarding journey", "满载而归"),
|
| 31 |
-
("omnipresent", "无所不在"),
|
| 32 |
-
],
|
| 33 |
-
)
|
| 34 |
-
def test_definition_returns_correct_idiom(situation, idiom):
|
| 35 |
-
"""if input situation is the same as the embedded English definition,
|
| 36 |
-
RAG implementation should return the correct Chinese idiom"""
|
| 37 |
-
top_k_idioms = retrieve_idiom(situation, top_k=3)
|
| 38 |
-
print(top_k_idioms)
|
| 39 |
-
assert any(idiom in s for s in top_k_idioms)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|