-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
37 lines (30 loc) · 1.32 KB
/
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
26
27
28
29
30
31
32
33
34
35
36
37
import unittest
from website import create_app
class TestFlaskApp(unittest.TestCase):
@classmethod
def setUpClass(cls):
"""Set up the test client for the Flask app."""
cls.app = create_app()
cls.app.testing = True
cls.client = cls.app.test_client()
def test_home_page(self):
"""Test the login page route."""
response = self.client.get('/')
self.assertEqual(response.status_code, 200)
self.assertIn(b'Login', response.data) # Adjust 'Welcome' based on your actual content
def test_about_page(self):
"""Test the sign-up page route."""
response = self.client.get('/sign-up')
self.assertEqual(response.status_code, 200)
self.assertIn(b'Sign-Up', response.data) # Adjust 'About' based on your actual content
def test_non_existent_page(self):
"""Test a non-existent page."""
response = self.client.get('/nonexistent')
self.assertEqual(response.status_code, 404)
# def test_post_route(self):
# """Test a POST route."""
# response = self.client.post('/submit', data=dict(name='test'))
# self.assertEqual(response.status_code, 200)
# self.assertIn(b'Success', response.data) # Adjust 'Success' based on your actual content
if __name__ == "__main__":
unittest.main()