# Path: google/resumable_media/common.py
# _SLEEP_RETRY_ERROR_MSG = (
#     "At most one of `max_cumulative_retry` and `max_retries` " "can be specified."
# )
# UPLOAD_CHUNK_SIZE = 262144  # 256 * 1024
# PERMANENT_REDIRECT = http.client.PERMANENT_REDIRECT  # type: ignore
# TOO_MANY_REQUESTS = http.client.TOO_MANY_REQUESTS
# MAX_SLEEP = 64.0
# MAX_CUMULATIVE_RETRY = 600.0
# RETRYABLE = (
#     http.client.TOO_MANY_REQUESTS,  # 429
#     http.client.REQUEST_TIMEOUT,  # 408
#     http.client.INTERNAL_SERVER_ERROR,  # 500
#     http.client.BAD_GATEWAY,  # 502
#     http.client.SERVICE_UNAVAILABLE,  # 503
#     http.client.GATEWAY_TIMEOUT,  # 504
# )
# class InvalidResponse(Exception):
# class DataCorruption(Exception):
# class RetryStrategy(object):
#     def __init__(self, response, *args):
#     def __init__(self, response, *args):
#     def __init__(
#         self,
#         max_sleep=MAX_SLEEP,
#         max_cumulative_retry=None,
#         max_retries=None,
#         initial_delay=1.0,
#         multiplier=2.0,
#     ):
#     def retry_allowed(self, total_sleep, num_retries):


import http.client
import mock
import pytest  # type: ignore
from google._async_resumable_media import _helpers
from google.resumable_media import common
                response, status_codes, self._get_status_code
            )
            assert value == status_code

    def test_success_with_callback(self):
        status_codes = (http.client.OK,)
        response = _make_response(http.client.OK)
        callback = mock.Mock(spec=[])
        status_code = _helpers.require_status_code(
            response, status_codes, self._get_status_code, callback=callback
        )
        assert status_code == http.client.OK
        callback.assert_not_called()

    def test_failure(self):
        status_codes = (http.client.CREATED, http.client.NO_CONTENT)
        response = _make_response(http.client.OK)
        with pytest.raises(common.InvalidResponse) as exc_info:
            _helpers.require_status_code(response, status_codes, self._get_status_code)

        error = exc_info.value
        assert error.response is response
        assert len(error.args) == 5
        assert error.args[1] == response.status_code
        assert error.args[3:] == status_codes

    def test_failure_with_callback(self):
        status_codes = (http.client.OK,)
        response = _make_response(http.client.NOT_FOUND)
        callback = mock.Mock(spec=[])

# Path: google/resumable_media/common.py
# _SLEEP_RETRY_ERROR_MSG = (
#     "At most one of `max_cumulative_retry` and `max_retries` " "can be specified."
# )
# UPLOAD_CHUNK_SIZE = 262144  # 256 * 1024
# PERMANENT_REDIRECT = http.client.PERMANENT_REDIRECT  # type: ignore
# TOO_MANY_REQUESTS = http.client.TOO_MANY_REQUESTS
# MAX_SLEEP = 64.0
# MAX_CUMULATIVE_RETRY = 600.0
# RETRYABLE = (
#     http.client.TOO_MANY_REQUESTS,  # 429
#     http.client.REQUEST_TIMEOUT,  # 408
#     http.client.INTERNAL_SERVER_ERROR,  # 500
#     http.client.BAD_GATEWAY,  # 502
#     http.client.SERVICE_UNAVAILABLE,  # 503
#     http.client.GATEWAY_TIMEOUT,  # 504
# )
# class InvalidResponse(Exception):
# class DataCorruption(Exception):
# class RetryStrategy(object):
#     def __init__(self, response, *args):
#     def __init__(self, response, *args):
#     def __init__(
#         self,
#         max_sleep=MAX_SLEEP,
#         max_cumulative_retry=None,
#         max_retries=None,
#         initial_delay=1.0,
#         multiplier=2.0,
#     ):
#     def retry_allowed(self, total_sleep, num_retries):


# Path: tests_async/unit/test__helpers.py
import http.client
import mock
import pytest  # type: ignore
from google._async_resumable_media import _helpers
from google.resumable_media import common

                response, status_codes, self._get_status_code
            )
            assert value == status_code

    def test_success_with_callback(self):
        status_codes = (http.client.OK,)
        response = _make_response(http.client.OK)
        callback = mock.Mock(spec=[])
        status_code = _helpers.require_status_code(
            response, status_codes, self._get_status_code, callback=callback
        )
        assert status_code == http.client.OK
        callback.assert_not_called()

    def test_failure(self):
        status_codes = (http.client.CREATED, http.client.NO_CONTENT)
        response = _make_response(http.client.OK)
        with pytest.raises(common.InvalidResponse) as exc_info:
            _helpers.require_status_code(response, status_codes, self._get_status_code)

        error = exc_info.value
        assert error.response is response
        assert len(error.args) == 5
        assert error.args[1] == response.status_code
        assert error.args[3:] == status_codes

    def test_failure_with_callback(self):
        status_codes = (http.client.OK,)
        response = _make_response(http.client.NOT_FOUND)
        callback = mock.Mock(spec=[])

        with pytest.raises(common.InvalidResponse) as exc_info: