-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_views.py
40 lines (30 loc) · 1.12 KB
/
test_views.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
38
39
40
import os
import tempfile
import unittest
from app import app
from app.model import create_db
class TestViews(unittest.TestCase):
def setUp(self):
self.db_test, app.config['DATABASE'] = tempfile.mkstemp()
app.config['TESTING'] = True
self.app = app.test_client()
create_db()
def tearDown(self):
os.close(self.db_test)
os.unlink(app.config['DATABASE'])
def logout(self):
return self.app.get('/logout', follow_redirects=True)
def test_index(self):
response = self.app.get('/')
assert response.status_code == 200
assert 'Package tracking for online shoppers' in response.data
def test_login(self):
response = self.app.get('/login')
assert response.status_code == 302
assert 'You should be redirected automatically to target URL: <a href="https://accounts.google.com/o/oauth2/auth' in response.data
def test_logout(self):
response = self.logout()
assert response.status_code == 200
assert 'Package tracking for online shoppers' in response.data
if __name__ == '__main__':
unittest.main()