Tbruand
commited on
Commit
·
bd73929
1
Parent(s):
ff35429
test(interface): ajoute des tests unitaires sur le wrapper interface
Browse files- tests/test_interface.py +33 -0
tests/test_interface.py
CHANGED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
import os
|
3 |
+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
4 |
+
|
5 |
+
from app.interface import predict
|
6 |
+
|
7 |
+
def test_predict_zero_shot():
|
8 |
+
result = predict("Tu es gentil.", model_type="zero-shot")
|
9 |
+
assert isinstance(result, str)
|
10 |
+
assert "Résultat de la classification" in result
|
11 |
+
|
12 |
+
def test_predict_few_shot():
|
13 |
+
result = predict("Tu es débile.", model_type="few-shot")
|
14 |
+
assert isinstance(result, str)
|
15 |
+
assert "Résultat de la classification" in result
|
16 |
+
|
17 |
+
def test_predict_empty_input():
|
18 |
+
try:
|
19 |
+
result = predict("", model_type="zero-shot")
|
20 |
+
except ValueError as e:
|
21 |
+
assert "at least one sequence" in str(e)
|
22 |
+
|
23 |
+
def test_predict_invalid_model():
|
24 |
+
try:
|
25 |
+
predict("Texte test", model_type="unknown")
|
26 |
+
except ValueError as e:
|
27 |
+
assert "Modèle inconnu" in str(e)
|
28 |
+
|
29 |
+
def test_create_interface():
|
30 |
+
from app.interface import create_interface
|
31 |
+
iface = create_interface()
|
32 |
+
assert iface.fn is not None
|
33 |
+
assert len(iface.input_components) == 2
|