# Path: google/resumable_media/_download.py
# _CONTENT_RANGE_RE = re.compile(
#     r"bytes (?P<start_byte>\d+)-(?P<end_byte>\d+)/(?P<total_bytes>\d+)",
#     flags=re.IGNORECASE,
# )
# _ACCEPTABLE_STATUS_CODES = (http.client.OK, http.client.PARTIAL_CONTENT)
# _GET = "GET"
# _ZERO_CONTENT_RANGE_HEADER = "bytes */0"
# class DownloadBase(object):
# class Download(DownloadBase):
# class ChunkedDownload(DownloadBase):
#     def __init__(self, media_url, stream=None, start=None, end=None, headers=None):
#     def finished(self):
#     def _get_status_code(response):
#     def _get_headers(response):
#     def _get_body(response):
#     def __init__(
#         self, media_url, stream=None, start=None, end=None, headers=None, checksum="md5"
#     ):
#     def _prepare_request(self):
#     def _process_response(self, response):
#     def consume(self, transport, timeout=None):
#     def __init__(self, media_url, chunk_size, stream, start=0, end=None, headers=None):
#     def bytes_downloaded(self):
#     def total_bytes(self):
#     def invalid(self):
#     def _get_byte_range(self):
#     def _prepare_request(self):
#     def _make_invalid(self):
#     def _process_response(self, response):
#     def consume_next_chunk(self, transport, timeout=None):
# def add_bytes_range(start, end, headers):
# def get_range_info(response, get_headers, callback=_helpers.do_nothing):
# def _check_for_zero_content_range(response, get_status_code, get_headers):
# 
# 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 io
import mock
import pytest  # type: ignore
from google.resumable_media import _download
from google.resumable_media import common

    def test_content_range_zero_only(self):
        content_range = _download._ZERO_CONTENT_RANGE_HEADER
        status_code = http.client.OK
        response = self._make_response(content_range, status_code)
        assert not _download._check_for_zero_content_range(
            response, _get_status_code, _get_headers
        )


def _get_status_code(response):
    return response.status_code


def _get_headers(response):
    return response.headers


def _get_body(response):
    return response.content


def _fix_up_virtual(download):
    download._get_status_code = _get_status_code
    download._get_headers = _get_headers
    download._get_body = _get_body


def _check_retry_strategy(download):
    retry_strategy = download._retry_strategy

# Path: google/resumable_media/_download.py
# _CONTENT_RANGE_RE = re.compile(
#     r"bytes (?P<start_byte>\d+)-(?P<end_byte>\d+)/(?P<total_bytes>\d+)",
#     flags=re.IGNORECASE,
# )
# _ACCEPTABLE_STATUS_CODES = (http.client.OK, http.client.PARTIAL_CONTENT)
# _GET = "GET"
# _ZERO_CONTENT_RANGE_HEADER = "bytes */0"
# class DownloadBase(object):
# class Download(DownloadBase):
# class ChunkedDownload(DownloadBase):
#     def __init__(self, media_url, stream=None, start=None, end=None, headers=None):
#     def finished(self):
#     def _get_status_code(response):
#     def _get_headers(response):
#     def _get_body(response):
#     def __init__(
#         self, media_url, stream=None, start=None, end=None, headers=None, checksum="md5"
#     ):
#     def _prepare_request(self):
#     def _process_response(self, response):
#     def consume(self, transport, timeout=None):
#     def __init__(self, media_url, chunk_size, stream, start=0, end=None, headers=None):
#     def bytes_downloaded(self):
#     def total_bytes(self):
#     def invalid(self):
#     def _get_byte_range(self):
#     def _prepare_request(self):
#     def _make_invalid(self):
#     def _process_response(self, response):
#     def consume_next_chunk(self, transport, timeout=None):
# def add_bytes_range(start, end, headers):
# def get_range_info(response, get_headers, callback=_helpers.do_nothing):
# def _check_for_zero_content_range(response, get_status_code, get_headers):
# 
# 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/unit/test__download.py
import http.client
import io
import mock
import pytest  # type: ignore
from google.resumable_media import _download
from google.resumable_media import common


    def test_content_range_zero_only(self):
        content_range = _download._ZERO_CONTENT_RANGE_HEADER
        status_code = http.client.OK
        response = self._make_response(content_range, status_code)
        assert not _download._check_for_zero_content_range(
            response, _get_status_code, _get_headers
        )


def _get_status_code(response):
    return response.status_code


def _get_headers(response):
    return response.headers


def _get_body(response):
    return response.content


def _fix_up_virtual(download):
    download._get_status_code = _get_status_code
    download._get_headers = _get_headers
    download._get_body = _get_body


def _check_retry_strategy(download):
    retry_strategy = download._retry_strategy

    assert isinstance(retry_strategy, common.RetryStrategy)