Spaces:
Sleeping
Sleeping
Mohammed Thameem commited on
Commit ·
8478871
1
Parent(s): 57ae406
modified test script
Browse files- tests/test_app.py +26 -8
tests/test_app.py
CHANGED
|
@@ -1,10 +1,28 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
|
| 4 |
-
from app import chat
|
| 5 |
|
| 6 |
-
def
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
assert
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import types
|
| 2 |
+
import app
|
| 3 |
|
|
|
|
| 4 |
|
| 5 |
+
def test_respond_function_exists():
|
| 6 |
+
"""Check that the app has a respond() function."""
|
| 7 |
+
assert hasattr(app, "respond")
|
| 8 |
+
assert callable(app.respond)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def test_respond_returns_generator():
|
| 12 |
+
"""respond() should return a generator when called with minimal args."""
|
| 13 |
+
# Fake OAuthToken object for testing (since we don't want to call real HF API in CI)
|
| 14 |
+
class DummyToken:
|
| 15 |
+
token = "dummy"
|
| 16 |
+
|
| 17 |
+
gen = app.respond(
|
| 18 |
+
message="I'm buying a bottle of water.",
|
| 19 |
+
history=[],
|
| 20 |
+
system_message="You are Sustainable.ai.",
|
| 21 |
+
max_tokens=10,
|
| 22 |
+
temperature=0.7,
|
| 23 |
+
top_p=0.9,
|
| 24 |
+
hf_token=DummyToken(),
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
# respond() is a generator, not a plain string
|
| 28 |
+
assert isinstance(gen, types.GeneratorType)
|