# Path: tests/unit/requests/test_upload.py
# URL_PREFIX = "https://www.googleapis.com/upload/storage/v1/b/{BUCKET}/o"
# SIMPLE_URL = URL_PREFIX + "?uploadType=media&name={OBJECT}"
# MULTIPART_URL = URL_PREFIX + "?uploadType=multipart"
# RESUMABLE_URL = URL_PREFIX + "?uploadType=resumable"
# ONE_MB = 1024 * 1024
# BASIC_CONTENT = "text/plain"
# JSON_TYPE = "application/json; charset=UTF-8"
# JSON_TYPE_LINE = b"content-type: application/json; charset=UTF-8\r\n"
# EXPECTED_TIMEOUT = (61, 60)
# class TestSimpleUpload(object):
# class TestMultipartUpload(object):
# class TestResumableUpload(object):
#     def test_transmit(self):
#     def test_transmit_w_custom_timeout(self):
#     def test_transmit(self, mock_get_boundary):
#     def test_transmit_w_custom_timeout(self, mock_get_boundary):
#     def test_initiate(self):
#     def test_initiate_w_custom_timeout(self):
#     def _upload_in_flight(data, headers=None):
#     def _chunk_mock(status_code, response_headers):
#     def test_transmit_next_chunk(self):
#     def test_transmit_next_chunk_w_custom_timeout(self):
#     def test_recover(self):
# def _make_response(status_code=http.client.OK, headers=None):


import http.client
import io
import json
import aiohttp  # type: ignore
import mock  # type: ignore
import pytest  # type: ignore
import google._async_resumable_media.requests.upload as upload_mod
from tests.unit.requests import test_upload as sync_test

        # Make request and check the return value (against the mock).
        response = await upload.transmit_next_chunk(transport, timeout=12.6)
        assert response is transport.request.return_value
        # Check that the state has been updated.
        assert upload._bytes_uploaded == chunk_size
        # Make sure the mock was called as expected.
        payload = data[:chunk_size]
        content_range = "bytes 0-{:d}/{:d}".format(chunk_size - 1, len(data))
        expected_headers = {
            "content-range": content_range,
            "content-type": BASIC_CONTENT,
        }
        transport.request.assert_called_once_with(
            "PUT",
            upload.resumable_url,
            data=payload,
            headers=expected_headers,
            timeout=12.6,
        )

    @pytest.mark.asyncio
    async def test_recover(self):
        upload = upload_mod.ResumableUpload(RESUMABLE_URL, ONE_MB)
        upload._invalid = True  # Make sure invalid.
        upload._stream = mock.Mock(spec=["seek"])
        upload._resumable_url = "http://test.invalid?upload_id=big-deal"

        end = 55555
        headers = {"range": "bytes=0-{:d}".format(end)}

# Path: tests/unit/requests/test_upload.py
# URL_PREFIX = "https://www.googleapis.com/upload/storage/v1/b/{BUCKET}/o"
# SIMPLE_URL = URL_PREFIX + "?uploadType=media&name={OBJECT}"
# MULTIPART_URL = URL_PREFIX + "?uploadType=multipart"
# RESUMABLE_URL = URL_PREFIX + "?uploadType=resumable"
# ONE_MB = 1024 * 1024
# BASIC_CONTENT = "text/plain"
# JSON_TYPE = "application/json; charset=UTF-8"
# JSON_TYPE_LINE = b"content-type: application/json; charset=UTF-8\r\n"
# EXPECTED_TIMEOUT = (61, 60)
# class TestSimpleUpload(object):
# class TestMultipartUpload(object):
# class TestResumableUpload(object):
#     def test_transmit(self):
#     def test_transmit_w_custom_timeout(self):
#     def test_transmit(self, mock_get_boundary):
#     def test_transmit_w_custom_timeout(self, mock_get_boundary):
#     def test_initiate(self):
#     def test_initiate_w_custom_timeout(self):
#     def _upload_in_flight(data, headers=None):
#     def _chunk_mock(status_code, response_headers):
#     def test_transmit_next_chunk(self):
#     def test_transmit_next_chunk_w_custom_timeout(self):
#     def test_recover(self):
# def _make_response(status_code=http.client.OK, headers=None):


# Path: tests_async/unit/requests/test_upload.py
import http.client
import io
import json
import aiohttp  # type: ignore
import mock  # type: ignore
import pytest  # type: ignore
import google._async_resumable_media.requests.upload as upload_mod
from tests.unit.requests import test_upload as sync_test


        # Make request and check the return value (against the mock).
        response = await upload.transmit_next_chunk(transport, timeout=12.6)
        assert response is transport.request.return_value
        # Check that the state has been updated.
        assert upload._bytes_uploaded == chunk_size
        # Make sure the mock was called as expected.
        payload = data[:chunk_size]
        content_range = "bytes 0-{:d}/{:d}".format(chunk_size - 1, len(data))
        expected_headers = {
            "content-range": content_range,
            "content-type": BASIC_CONTENT,
        }
        transport.request.assert_called_once_with(
            "PUT",
            upload.resumable_url,
            data=payload,
            headers=expected_headers,
            timeout=12.6,
        )

    @pytest.mark.asyncio
    async def test_recover(self):
        upload = upload_mod.ResumableUpload(RESUMABLE_URL, ONE_MB)
        upload._invalid = True  # Make sure invalid.
        upload._stream = mock.Mock(spec=["seek"])
        upload._resumable_url = "http://test.invalid?upload_id=big-deal"

        end = 55555
        headers = {"range": "bytes=0-{:d}".format(end)}

        transport = self._chunk_mock(http.client.PERMANENT_REDIRECT, headers)