'Returns an in-memory file of the specified type with the given name for testing'

def get_sample_asset(self, name, asset_type='text'):

    sample_asset = BytesIO()
    sample_file_contents = 'This    file    is    generated    by    python    unit    test'
    if (asset_type == 'text'):
        sample_asset.name = '{name}.txt'.format(name=name)
        sample_asset.write(sample_file_contents)
    elif (asset_type == 'image'):
        image = Image.new('RGB', size=(50, 50), color=(256, 0, 0))
        image.save(sample_asset, 'jpeg')
        sample_asset.name = '{name}.jpg'.format(name=name)
    elif (asset_type == 'opendoc'):
        sample_asset.name = '{name}.odt'.format(name=name)
        sample_asset.write(sample_file_contents)
    sample_asset.seek(0)
    return sample_asset
