def test_can_honor_max_attempts(): checker = standard.MaxAttemptsChecker(max_attempts=3) context = arbitrary_retry_context() context.attempt_number = 1 assert_equal(checker.is_retryable(context), True) context.attempt_number = 2 assert_equal(checker.is_retryable(context), True) context.attempt_number = 3 assert_equal(checker.is_retryable(context), False)
def test_max_attempts_adds_metadata_key_when_reached(): checker = standard.MaxAttemptsChecker(max_attempts=3) context = arbitrary_retry_context() context.attempt_number = 3 assert_equal(checker.is_retryable(context), False) assert_equal(context.get_retry_metadata(), {'MaxAttemptsReached': True})
def test_retries_context_not_on_request_context(): checker = standard.MaxAttemptsChecker(max_attempts=3) context = arbitrary_retry_context() context.attempt_number = 3 assert checker.is_retryable(context) is False assert context.request_context == {}