def test_s3object_to_asset_binary(): resp = stubs.s3get_response_binary() bobj = localresource.from_s3object(resp) assert bobj.content_length == resp['ContentLength'] assert bobj.contenttype == resp['ContentType'] assert bobj.last_modified == resp['LastModified'] assert bobj.metadata == resp['Metadata'] assert bobj.resourcetype == resp['Metadata']['resourcetype'] assert bobj.content == stubs.binary_content
def test_s3object_to_asset_json(): bobj = localresource.from_s3object(stubs.s3get_response_json()) assert bobj.content == stubs.json_content assert bobj.data == json.loads(stubs.json_content)
def test_s3object_to_asset_text(): bobj = localresource.from_s3object(stubs.s3get_response_text_utf8()) assert bobj.content == stubs.text_content.encode('utf-8') assert bobj.text == stubs.text_content
def test_s3object_to_asset_binary_has_no_json(): bobj = localresource.from_s3object(stubs.s3get_response_binary()) assert bobj.content == stubs.binary_content with pytest.raises(ValueError): assert bobj.data == stubs.binary_content