# Path: google/_async_resumable_media/requests/_request_helpers.py
# _DEFAULT_RETRY_STRATEGY = common.RetryStrategy()
# _SINGLE_GET_CHUNK_SIZE = 8192
# _DEFAULT_CONNECT_TIMEOUT = 61
# _DEFAULT_READ_TIMEOUT = 60
# _DEFAULT_TIMEOUT = aiohttp.ClientTimeout(
#     connect=_DEFAULT_CONNECT_TIMEOUT, sock_read=_DEFAULT_READ_TIMEOUT
# )
# class RequestsMixin(object):
# class RawRequestsMixin(RequestsMixin):
#     def _get_status_code(response):
#     def _get_headers(response):
#     async def _get_body(response):
#     async def _get_body(response):
# async def http_request(
#     transport,
#     method,
#     url,
#     data=None,
#     headers=None,
#     retry_strategy=_DEFAULT_RETRY_STRATEGY,
#     **transport_kwargs
# ):


import http.client
import io
import aiohttp  # type: ignore
import mock
import pytest  # type: ignore
from google._async_resumable_media.requests import _request_helpers as _helpers




# async version takes a single timeout, not a tuple of connect, read timeouts.
EXPECTED_TIMEOUT = aiohttp.ClientTimeout(connect=61, sock_read=60)


class TestRequestsMixin(object):
    def test__get_status_code(self):
        status_code = int(http.client.OK)
        response = _make_response(status_code)
        assert status_code == _helpers.RequestsMixin._get_status_code(response)

    def test__get_headers(self):
        headers = {"fruit": "apple"}
        response = mock.Mock(
            _headers=headers, headers=headers, spec=["_headers", "headers"]
        )
        assert headers == _helpers.RequestsMixin._get_headers(response)

    @pytest.mark.asyncio
    async def test__get_body(self):
        body = b"This is the payload."
        content_stream = mock.AsyncMock(spec=["__call__", "read"])
        content_stream.read = mock.AsyncMock(spec=["__call__"], return_value=body)
        response = mock.AsyncMock(
            content=content_stream,
            spec=["__call__", "content"],
        )

# Path: google/_async_resumable_media/requests/_request_helpers.py
# _DEFAULT_RETRY_STRATEGY = common.RetryStrategy()
# _SINGLE_GET_CHUNK_SIZE = 8192
# _DEFAULT_CONNECT_TIMEOUT = 61
# _DEFAULT_READ_TIMEOUT = 60
# _DEFAULT_TIMEOUT = aiohttp.ClientTimeout(
#     connect=_DEFAULT_CONNECT_TIMEOUT, sock_read=_DEFAULT_READ_TIMEOUT
# )
# class RequestsMixin(object):
# class RawRequestsMixin(RequestsMixin):
#     def _get_status_code(response):
#     def _get_headers(response):
#     async def _get_body(response):
#     async def _get_body(response):
# async def http_request(
#     transport,
#     method,
#     url,
#     data=None,
#     headers=None,
#     retry_strategy=_DEFAULT_RETRY_STRATEGY,
#     **transport_kwargs
# ):


# Path: tests_async/unit/requests/test__helpers.py
import http.client
import io
import aiohttp  # type: ignore
import mock
import pytest  # type: ignore
from google._async_resumable_media.requests import _request_helpers as _helpers





# async version takes a single timeout, not a tuple of connect, read timeouts.
EXPECTED_TIMEOUT = aiohttp.ClientTimeout(connect=61, sock_read=60)


class TestRequestsMixin(object):
    def test__get_status_code(self):
        status_code = int(http.client.OK)
        response = _make_response(status_code)
        assert status_code == _helpers.RequestsMixin._get_status_code(response)

    def test__get_headers(self):
        headers = {"fruit": "apple"}
        response = mock.Mock(
            _headers=headers, headers=headers, spec=["_headers", "headers"]
        )
        assert headers == _helpers.RequestsMixin._get_headers(response)

    @pytest.mark.asyncio
    async def test__get_body(self):
        body = b"This is the payload."
        content_stream = mock.AsyncMock(spec=["__call__", "read"])
        content_stream.read = mock.AsyncMock(spec=["__call__"], return_value=body)
        response = mock.AsyncMock(
            content=content_stream,
            spec=["__call__", "content"],
        )

        temp = await _helpers.RequestsMixin._get_body(response)