Example #1
0
async def responses_double():
    # mimics aiohttp.ClientResponse
    response1 = AsyncMock()
    response1.headers = {"Content-Range": "bytes 0-63/65"}
    response1.status = 206
    response1.read = AsyncMock(return_value=b"X" * 64)
    response2 = AsyncMock()
    response2.headers = {"Content-Range": "bytes 64-64/65"}
    response2.status = 206
    response2.read = AsyncMock(return_value=b"X")
    return [response1, response2]
Example #2
0
async def responses_single():
    # mimics aiohttp.ClientResponse
    response = AsyncMock()
    response.headers = {"Content-Range": "bytes 0-41/42"}
    response.status = 206
    response.read = AsyncMock(return_value=b"X" * 42)
    return [response]
Example #3
0
async def test_upload_fileobj_non_binary_file():
    string_io = AsyncMock()
    string_io.read = AsyncMock(return_value="some string")
    with pytest.raises(IOError, match="The file object is not in binary*"):
        await upload_fileobj("some-url", string_io)