-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
40 lines (28 loc) · 978 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
"""Tests for the Flask Heroku template."""
import unittest
from app import app
class TestApp(unittest.TestCase):
def setUp(self):
self.app = app.test_client()
def test_home_page_works(self):
rv = self.app.get('/')
self.assertTrue(rv.data)
self.assertEqual(rv.status_code, 200)
def test_about_page_works(self):
rv = self.app.get('/about/')
self.assertTrue(rv.data)
self.assertEqual(rv.status_code, 200)
def test_default_redirecting(self):
rv = self.app.get('/about')
self.assertEqual(rv.status_code, 301)
def test_404_page(self):
rv = self.app.get('/i-am-not-found/')
self.assertEqual(rv.status_code, 404)
def test_static_text_file_request(self):
rv = self.app.get('/robots.txt')
self.assertTrue(rv.data)
self.assertEqual(rv.status_code, 200)
rv.close()
if __name__ == '__main__':
unittest.main()