def test_handle_yields_successful_equals_false_when_status_code_is_504( self): STATUS_CODE = 504 RESPONSE = ResponseMock(STATUS_CODE) result = _response_handler.handle(RESPONSE) self.assertFalse(result["successful"])
def test_handle_yields_default_delay_when_status_code_is_503(self): STATUS_CODE = 503 RESPONSE = ResponseMock(STATUS_CODE) result = _response_handler.handle(RESPONSE) self.assertEqual(result["delay"], _response_handler._DEFAULT_DELAY_FOR_STATUS_CODE_503)
def test_handle_yields_retry_equals_true_when_status_code_is_429(self): STATUS_CODE = 429 HEADERS = {"Retry-After": 0} RESPONSE = ResponseMock(STATUS_CODE, headers=HEADERS) result = _response_handler.handle(RESPONSE) self.assertTrue(result["retry"])
def test_handle_yields_successful_equals_true_when_status_code_is_200( self): STATUS_CODE = 200 RESPONSE = ResponseMock(STATUS_CODE) result = _response_handler.handle(RESPONSE) self.assertTrue(result["successful"])
def test_handle_yields_retry_after_header_as_delay_when_status_code_is_429( self): STATUS_CODE = 429 HEADERS = {"Retry-After": 10} RESPONSE = ResponseMock(STATUS_CODE, headers=HEADERS) result = _response_handler.handle(RESPONSE) self.assertEqual(result["delay"], HEADERS["Retry-After"])