def test_status_categories(self): assert not status.is_informational(99) assert status.is_informational(100) assert status.is_informational(199) assert not status.is_informational(200) assert not status.is_success(199) assert status.is_success(200) assert status.is_success(299) assert not status.is_success(300) assert not status.is_redirect(299) assert status.is_redirect(300) assert status.is_redirect(399) assert not status.is_redirect(400) assert not status.is_client_error(399) assert status.is_client_error(400) assert status.is_client_error(499) assert not status.is_client_error(500) assert not status.is_server_error(499) assert status.is_server_error(500) assert status.is_server_error(599) assert not status.is_server_error(600)
def test_status_categories(self): self.assertFalse(status.is_informational(99)) self.assertTrue(status.is_informational(100)) self.assertTrue(status.is_informational(199)) self.assertFalse(status.is_informational(200)) self.assertFalse(status.is_success(199)) self.assertTrue(status.is_success(200)) self.assertTrue(status.is_success(299)) self.assertFalse(status.is_success(300)) self.assertFalse(status.is_redirect(299)) self.assertTrue(status.is_redirect(300)) self.assertTrue(status.is_redirect(399)) self.assertFalse(status.is_redirect(400)) self.assertFalse(status.is_client_error(399)) self.assertTrue(status.is_client_error(400)) self.assertTrue(status.is_client_error(499)) self.assertFalse(status.is_client_error(500)) self.assertFalse(status.is_server_error(499)) self.assertTrue(status.is_server_error(500)) self.assertTrue(status.is_server_error(599)) self.assertFalse(status.is_server_error(600))
def get_status(status_code: int) -> AnyStr: """ To determine the type of response based on status_code :param status_code: Integer value ranging 200-500 :return: String """ if status.is_success(status_code) or status.is_redirect(status_code): return "SUCCESS" elif status.is_client_error(status_code): return "FAILURE" else: return "ERROR"
def test_users_can_logout(self): """ Tests if user can logout. """ with self.client: self.client.post('/login', data={ 'username': '******', 'password': '******' }, follow_redirects=True) response = self.client.get('/logout') username = current_user.username if not current_user.is_anonymous else 'anonymous' self.assertTrue(current_user.is_anonymous, msg=f'user <{username}> is ' f'still logged in') self.assertTrue(status.is_redirect(response.status_code))