Exemplo n.º 1
0
    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"])
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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"])
Exemplo n.º 4
0
    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"])
Exemplo n.º 5
0
    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"])