# 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
        )
        download._process_response(response)
        stream.write.assert_not_called()
        assert download.finished
        assert download.bytes_downloaded == 0
        assert download.total_bytes is None

    def test_consume_next_chunk(self):
        download = _download.ChunkedDownload(EXAMPLE_URL, 256, None)
        with pytest.raises(NotImplementedError) as exc_info:
            download.consume_next_chunk(None)

        exc_info.match("virtual")


class Test__add_bytes_range(object):
    def test_do_nothing(self):
        headers = {}
        ret_val = _download.add_bytes_range(None, None, headers)
        assert ret_val is None
        assert headers == {}

    def test_both_vals(self):
        headers = {}
        ret_val = _download.add_bytes_range(17, 1997, headers)
        assert ret_val is None
        assert headers == {"range": "bytes=17-1997"}

    def test_end_only(self):
        headers = {}

# 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

        )
        download._process_response(response)
        stream.write.assert_not_called()
        assert download.finished
        assert download.bytes_downloaded == 0
        assert download.total_bytes is None

    def test_consume_next_chunk(self):
        download = _download.ChunkedDownload(EXAMPLE_URL, 256, None)
        with pytest.raises(NotImplementedError) as exc_info:
            download.consume_next_chunk(None)

        exc_info.match("virtual")


class Test__add_bytes_range(object):
    def test_do_nothing(self):
        headers = {}
        ret_val = _download.add_bytes_range(None, None, headers)
        assert ret_val is None
        assert headers == {}

    def test_both_vals(self):
        headers = {}
        ret_val = _download.add_bytes_range(17, 1997, headers)
        assert ret_val is None
        assert headers == {"range": "bytes=17-1997"}

    def test_end_only(self):
        headers = {}

        ret_val = _download.add_bytes_range(None, 909, headers)