Mohammed Thameem commited on
Commit
8478871
·
1 Parent(s): 57ae406

modified test script

Browse files
Files changed (1) hide show
  1. tests/test_app.py +26 -8
tests/test_app.py CHANGED
@@ -1,10 +1,28 @@
1
- import sys, os
2
- sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
3
 
4
- from app import chat
5
 
6
- def test_chat_response():
7
- user_input = "I'm buying a plastic bottle of water."
8
- response = chat(user_input)
9
- assert isinstance(response, str)
10
- assert len(response) > 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)