| 6 | |
| 7 | |
| 8 | class FlaskTestCase(BaseTestCase): |
| 9 | |
| 10 | # Ensure that Flask was set up correctly |
| 11 | def test_index(self): |
| 12 | response = self.client.get('/login', content_type='html/text') |
| 13 | self.assertEqual(response.status_code, 200) |
| 14 | |
| 15 | # Ensure that main page requires user login |
| 16 | def test_main_route_requires_login(self): |
| 17 | response = self.client.get('/', follow_redirects=True) |
| 18 | self.assertIn(b'Please log in to access this page', response.data) |
| 19 | |
| 20 | # Ensure that welcome page loads |
| 21 | def test_welcome_route_works_as_expected(self): |
| 22 | response = self.client.get('/welcome', follow_redirects=True) |
| 23 | self.assertIn(b'Welcome to Flask!', response.data) |
| 24 | |
| 25 | # Ensure that posts show up on the main page |
| 26 | def test_posts_show_up_on_main_page(self): |
| 27 | response = self.client.post( |
| 28 | '/login', |
| 29 | data=dict(username="admin", password="admin"), |
| 30 | follow_redirects=True |
| 31 | ) |
| 32 | self.assertIn(b'This is a test. Only a test.', response.data) |
| 33 | |
| 34 | |
| 35 | if __name__ == '__main__': |
nothing calls this directly
no outgoing calls
no test coverage detected