# Path: google/resumable_media/_helpers.py
# RANGE_HEADER = "range"
# CONTENT_RANGE_HEADER = "content-range"
# _SLOW_CRC32C_WARNING = (
#     "Currently using crcmod in pure python form. This is a slow "
#     "implementation. Python 3 has a faster implementation, `google-crc32c`, "
#     "which will be used if it is installed."
# )
# _GENERATION_HEADER = "x-goog-generation"
# _HASH_HEADER = "x-goog-hash"
# _MISSING_CHECKSUM = """\
# No {checksum_type} checksum was returned from the service while downloading {}
# (which happens for composite objects), so client-side content integrity
# checking is not being performed."""
# _LOGGER = logging.getLogger(__name__)
# def do_nothing():
# def header_required(response, name, get_headers, callback=do_nothing):
# def require_status_code(response, status_codes, get_status_code, callback=do_nothing):
# def calculate_retry_wait(base_wait, max_sleep, multiplier=2.0):
# def _get_crc32c_object():
# def _is_fast_crcmod():
# def _get_metadata_key(checksum_type):
# def prepare_checksum_digest(digest_bytestring):
# def _get_expected_checksum(response, get_headers, media_url, checksum_type):
# def _parse_checksum_header(header_value, response, checksum_label):
# def _get_checksum_object(checksum_type):
# def _parse_generation_header(response, get_headers):
# def _get_generation_from_url(media_url):
# def add_query_parameters(media_url, query_params):
#     def update(self, unused_chunk):
# class _DoNothingHash(object):
# 
# 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 hashlib
import http.client
import mock
import pytest  # type: ignore
from google.resumable_media import _helpers
from google.resumable_media import common
        md5_header = _helpers._parse_checksum_header(
            header_value, response, checksum_label="md5"
        )
        assert md5_header is None
        crc32c_header = _helpers._parse_checksum_header(
            header_value, response, checksum_label="crc32c"
        )
        assert crc32c_header == self.CRC32C_CHECKSUM

    def test_md5_only(self):
        header_value = "md5={}".format(self.MD5_CHECKSUM)
        response = None
        md5_header = _helpers._parse_checksum_header(
            header_value, response, checksum_label="md5"
        )
        assert md5_header == self.MD5_CHECKSUM
        crc32c_header = _helpers._parse_checksum_header(
            header_value, response, checksum_label="crc32c"
        )
        assert crc32c_header is None

    def test_both_crc32c_and_md5(self):
        header_value = "crc32c={},md5={}".format(
            self.CRC32C_CHECKSUM, self.MD5_CHECKSUM
        )
        response = None
        md5_header = _helpers._parse_checksum_header(
            header_value, response, checksum_label="md5"
        )
        assert md5_header == self.MD5_CHECKSUM

# Path: google/resumable_media/_helpers.py
# RANGE_HEADER = "range"
# CONTENT_RANGE_HEADER = "content-range"
# _SLOW_CRC32C_WARNING = (
#     "Currently using crcmod in pure python form. This is a slow "
#     "implementation. Python 3 has a faster implementation, `google-crc32c`, "
#     "which will be used if it is installed."
# )
# _GENERATION_HEADER = "x-goog-generation"
# _HASH_HEADER = "x-goog-hash"
# _MISSING_CHECKSUM = """\
# No {checksum_type} checksum was returned from the service while downloading {}
# (which happens for composite objects), so client-side content integrity
# checking is not being performed."""
# _LOGGER = logging.getLogger(__name__)
# def do_nothing():
# def header_required(response, name, get_headers, callback=do_nothing):
# def require_status_code(response, status_codes, get_status_code, callback=do_nothing):
# def calculate_retry_wait(base_wait, max_sleep, multiplier=2.0):
# def _get_crc32c_object():
# def _is_fast_crcmod():
# def _get_metadata_key(checksum_type):
# def prepare_checksum_digest(digest_bytestring):
# def _get_expected_checksum(response, get_headers, media_url, checksum_type):
# def _parse_checksum_header(header_value, response, checksum_label):
# def _get_checksum_object(checksum_type):
# def _parse_generation_header(response, get_headers):
# def _get_generation_from_url(media_url):
# def add_query_parameters(media_url, query_params):
#     def update(self, unused_chunk):
# class _DoNothingHash(object):
# 
# 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__helpers.py
import hashlib
import http.client
import mock
import pytest  # type: ignore
from google.resumable_media import _helpers
from google.resumable_media import common

        md5_header = _helpers._parse_checksum_header(
            header_value, response, checksum_label="md5"
        )
        assert md5_header is None
        crc32c_header = _helpers._parse_checksum_header(
            header_value, response, checksum_label="crc32c"
        )
        assert crc32c_header == self.CRC32C_CHECKSUM

    def test_md5_only(self):
        header_value = "md5={}".format(self.MD5_CHECKSUM)
        response = None
        md5_header = _helpers._parse_checksum_header(
            header_value, response, checksum_label="md5"
        )
        assert md5_header == self.MD5_CHECKSUM
        crc32c_header = _helpers._parse_checksum_header(
            header_value, response, checksum_label="crc32c"
        )
        assert crc32c_header is None

    def test_both_crc32c_and_md5(self):
        header_value = "crc32c={},md5={}".format(
            self.CRC32C_CHECKSUM, self.MD5_CHECKSUM
        )
        response = None
        md5_header = _helpers._parse_checksum_header(
            header_value, response, checksum_label="md5"
        )
        assert md5_header == self.MD5_CHECKSUM

        crc32c_header = _helpers._parse_checksum_header(