-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
25 lines (19 loc) · 837 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import unittest
import app
class TestApp(unittest.TestCase):
def setUp(self):
self.app = app.app.test_client()
def test_generate_response(self):
prompt = "Q: What is the meaning of life?\nA:"
response = app.generate_response(prompt)
self.assertIsInstance(response, str)
def test_homepage(self):
response = self.app.get('/')
self.assertEqual(response.status_code, 200)
self.assertIn(b'Ask a question or enter a prompt:', response.data)
def test_submit_message(self):
response = self.app.post('/result', data=dict(prompt='What is the meaning of life?'), follow_redirects=True)
self.assertEqual(response.status_code, 200)
self.assertIn(b'You Asked:', response.data)
if __name__ == '__main__':
unittest.main()