Example #1
0
def test_download_image_none():
    session = aiohttp.ClientSession()
    image_url = 'http://i.imgur.com/0d4I9Pz.jp'
    image_folder = '.'
    image_name = 'test.jpg'
    result = yield from aiodcard.download_image(session, image_url, image_folder, image_name)
    session.close()
    assert result['result'] == -1
Example #2
0
def test_download_image():
    import os
    session = aiohttp.ClientSession()
    image_url = 'http://i.imgur.com/3Tsokox.jpg'
    image_folder = '.'
    image_name = 'test.jpg'
    result = yield from aiodcard.download_image(session, image_url, image_folder, image_name)
    assert result['result'] == 0

    statinfo = os.stat(os.path.join(image_folder, image_name))
    session.close()
    assert statinfo.st_size == 457612
    os.remove(os.path.join(image_folder, image_name))