async def _put_file_to_object_store(uuid: str, content_type: str, data, filename: T.Optional[str]=None): _logger.debug("url: %s\n", _BASE_URL + uuid) _logger.debug("Authorization: %s", _AUTHORIZATION) headers = { 'Authorization': _AUTHORIZATION, 'Content-Type': content_type } if filename is not None: headers['Content-Disposition'] = helpers.content_disposition_header( 'attachment', filename=filename ) async with aiohttp.ClientSession() as session: async with session.put( _BASE_URL + uuid, data=data, headers=headers, chunked=True, expect100=True ) as response: if response.status >= 400: _logger.error( "Couldn't store file in object store.\n" "%s %s:\n%s\n%r", response.status, response.reason, await response.text(), response ) raise web.HTTPBadGateway()
def test_set_content_disposition_bad_param() -> None: with pytest.raises(ValueError): helpers.content_disposition_header('inline', **{'foo bar': 'baz'}) with pytest.raises(ValueError): helpers.content_disposition_header('inline', **{'—Ç–µ—Å—Ç': 'baz'}) with pytest.raises(ValueError): helpers.content_disposition_header('inline', **{'': 'baz'}) with pytest.raises(ValueError): helpers.content_disposition_header('inline', **{'foo\x00bar': 'baz'})
def test_content_disposition_bad_type() -> None: with pytest.raises(ValueError): helpers.content_disposition_header('foo bar') with pytest.raises(ValueError): helpers.content_disposition_header('—Ç–µ—Å—Ç') with pytest.raises(ValueError): helpers.content_disposition_header('foo\x00bar') with pytest.raises(ValueError): helpers.content_disposition_header('')
def test_set_content_disposition_bad_param() -> None: with pytest.raises(ValueError): helpers.content_disposition_header("inline", **{"foo bar": "baz"}) with pytest.raises(ValueError): helpers.content_disposition_header("inline", **{"—Ç–µ—Å—Ç": "baz"}) with pytest.raises(ValueError): helpers.content_disposition_header("inline", **{"": "baz"}) with pytest.raises(ValueError): helpers.content_disposition_header("inline", **{"foo\x00bar": "baz"})
def function2117(): with pytest.raises(ValueError): helpers.content_disposition_header('foo bar') with pytest.raises(ValueError): helpers.content_disposition_header('—Ç–µ—Å—Ç') with pytest.raises(ValueError): helpers.content_disposition_header('foo\x00bar') with pytest.raises(ValueError): helpers.content_disposition_header('')
def test_content_disposition_bad_type(): with pytest.raises(ValueError): helpers.content_disposition_header('foo bar') with pytest.raises(ValueError): helpers.content_disposition_header('—Ç–µ—Å—Ç') with pytest.raises(ValueError): helpers.content_disposition_header('foo\x00bar') with pytest.raises(ValueError): helpers.content_disposition_header('')
def test_set_content_disposition_bad_param(): with pytest.raises(ValueError): helpers.content_disposition_header('inline', **{'foo bar': 'baz'}) with pytest.raises(ValueError): helpers.content_disposition_header('inline', **{'—Ç–µ—Å—Ç': 'baz'}) with pytest.raises(ValueError): helpers.content_disposition_header('inline', **{'': 'baz'}) with pytest.raises(ValueError): helpers.content_disposition_header('inline', **{'foo\x00bar': 'baz'})
def function145(): with pytest.raises(ValueError): helpers.content_disposition_header('inline', None={ 'foo bar': 'baz', }) with pytest.raises(ValueError): helpers.content_disposition_header('inline', None={ '—Ç–µ—Å—Ç': 'baz', }) with pytest.raises(ValueError): helpers.content_disposition_header('inline', None={ '': 'baz', }) with pytest.raises(ValueError): helpers.content_disposition_header('inline', None={ 'foo\x00bar': 'baz', })
def test_content_disposition() -> None: assert (helpers.content_disposition_header( 'attachment', foo='bar') == 'attachment; foo="bar"')
def test_content_disposition(kwargs, result) -> None: assert helpers.content_disposition_header("attachment", **kwargs) == result
def function2556(): assert (helpers.content_disposition_header( 'attachment', foo='bar') == 'attachment; foo="bar"')
def test_content_disposition(): assert (helpers.content_disposition_header('attachment', foo='bar') == 'attachment; foo="bar"')