-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_app.py
More file actions
45 lines (36 loc) · 1.56 KB
/
test_app.py
File metadata and controls
45 lines (36 loc) · 1.56 KB
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
38
39
40
41
42
43
44
45
import unittest
from run import app # Import your Flask app here
class SimpleTwitterTestCase(unittest.TestCase):
def setUp(self):
self.app = app
self.client = self.app.test_client()
self.app.config['TESTING'] = True
self.app.config['WTF_CSRF_ENABLED'] = False # Disable CSRF for testing
def test_home_page(self):
response = self.client.get('/')
self.assertEqual(response.status_code, 302)
self.assertTrue('/login' in response.location)
def test_registration_page(self):
response = self.client.get('/register')
self.assertEqual(response.status_code, 200)
self.assertIn(b'Register', response.data)
def test_login_page(self):
response = self.client.get('/login')
self.assertEqual(response.status_code, 200)
self.assertIn(b'Login', response.data)
# def test_user_registration(self):
# response = self.client.post('/register', data=dict(
# username='testuser',
# password='testpassword'
# ), follow_redirects=True)
# self.assertIn(b'Login', response.data)
# def test_user_login(self):
# # Ensure you have a user to login with, might need to create one first.
# response = self.client.post('/login', data=dict(
# username='testuser',
# password='testpassword'
# ), follow_redirects=True)
# self.assertIn(b'Post a Chat', response.data)
# Add more tests for posting chats, following users, etc.
if __name__ == '__main__':
unittest.main()