| Total Complexity | 10 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | #! ../env/bin/python |
||
| 9 | @pytest.mark.usefixtures("testapp") |
||
| 10 | class TestURLs: |
||
| 11 | def test_home(self, testapp): |
||
| 12 | """ Tests if the home page loads """ |
||
| 13 | |||
| 14 | rv = testapp.get('/') |
||
| 15 | assert rv.status_code == 200 |
||
| 16 | |||
| 17 | def test_login(self, testapp): |
||
| 18 | """ Tests if the login page loads """ |
||
| 19 | |||
| 20 | rv = testapp.get('/login') |
||
| 21 | assert rv.status_code == 200 |
||
| 22 | |||
| 23 | def test_logout(self, testapp): |
||
| 24 | """ Tests if the logout page loads """ |
||
| 25 | |||
| 26 | rv = testapp.get('/logout') |
||
| 27 | assert rv.status_code == 302 |
||
| 28 | |||
| 29 | def test_restricted_logged_out(self, testapp): |
||
| 30 | """ Tests if the restricted page returns a 302 |
||
| 31 | if the user is logged out |
||
| 32 | """ |
||
| 33 | |||
| 34 | rv = testapp.get('/restricted') |
||
| 35 | assert rv.status_code == 302 |
||
| 36 | |||
| 37 | def test_restricted_logged_in(self, testapp): |
||
| 38 | """ Tests if the restricted page returns a 200 |
||
| 39 | if the user is logged in |
||
| 40 | """ |
||
| 41 | |||
| 42 | testapp.post('/login', data=dict( |
||
| 43 | username='admin', |
||
| 44 | password="supersafepassword" |
||
| 45 | ), follow_redirects=True) |
||
| 46 | |||
| 47 | rv = testapp.get('/restricted') |
||
| 48 | assert rv.status_code == 200 |
||
| 49 |