def test_status_categories(self): self.assertFalse(is_informational(99)) self.assertTrue(is_informational(100)) self.assertTrue(is_informational(199)) self.assertFalse(is_informational(200)) self.assertFalse(is_success(199)) self.assertTrue(is_success(200)) self.assertTrue(is_success(299)) self.assertFalse(is_success(300)) self.assertFalse(is_redirect(299)) self.assertTrue(is_redirect(300)) self.assertTrue(is_redirect(399)) self.assertFalse(is_redirect(400)) self.assertFalse(is_client_error(399)) self.assertTrue(is_client_error(400)) self.assertTrue(is_client_error(499)) self.assertFalse(is_client_error(500)) self.assertFalse(is_server_error(499)) self.assertTrue(is_server_error(500)) self.assertTrue(is_server_error(599)) self.assertFalse(is_server_error(600))
def assertResponseInformational(self, response, msg=None): status_code = response.status_code if msg is not None: message = msg.format(status_code=status_code, response_data=response.data) else: message = None self.assertTrue(status.is_informational(status_code), message)
def __init__(self, data=None, status=None, message=None): super(AppResponse, self).__init__(None, status=status) status_message = "" try: if is_informational(status): status_message = "informational" elif is_success(status): status_message = "ok" elif is_redirect(status): status_message = "redirect" elif is_client_error(status): status_message = "client_error" elif is_server_error(status): status_message = "server_error" except TypeError: status_message = "" self.data = { 'data': data, 'status_message': status_message, 'message': message }
def assertStatusInformational(self, response): self.assertTrue(status.is_informational(response.status_code))