Beispiel #1
0
def test_file_already_downloaded():
    _dir = _mktempdir()
    _fn = os.path.join(_dir, _data['success']['name'])
    #
    res1 = download.file(_data['success']['url'], filename=_fn)
    res2 = download.file(_data['success']['url'], filename=_fn)
    #
    assert res1 == res2
    _rmtempdir(_dir)
Beispiel #2
0
def test_specify_filename():
    _fn = 'test_filename.ext'
    #
    res = download.file(_data['success']['url'], filename=_fn)
    #
    assert res
    assert res == _fn
    assert os.path.isfile(_fn)
    os.remove(res)
Beispiel #3
0
def test_existing_absolute_path():
    _dir = _mktempdir()
    _fn = os.path.join(_dir, _data['success']['name'])
    #
    res = download.file(_data['success']['url'], filename=_fn)
    #
    assert res
    assert os.path.isfile(res)
    assert os.path.dirname(res) == _dir
    _rmtempdir(_dir)
Beispiel #4
0
def test_nonexisting_path_no_create():
    _dir = _mktempdir()
    _dirnon = os.path.join(_dir, 'nonexistent', 'directory')
    _fn = os.path.join(_dirnon, _data['success']['name'])
    #
    res = download.file(_data['success']['url'], filename=_fn, make_dirs=False)
    #
    assert res is None
    assert not os.path.isdir(_dirnon)
    _rmtempdir(_dir)
Beispiel #5
0
def test_nonexisting_path_create():
    # Default
    _dir = _mktempdir()
    _dir = os.path.join(_dir, 'nonexistent', 'directory')
    _fn = os.path.join(_dir, _data['success']['name'])
    #
    # By default, make the necessary path/directories (make_dirs=True)
    res = download.file(_data['success']['url'], filename=_fn)
    #
    assert res
    assert os.path.isfile(res)
    assert os.path.dirname(res) == _dir
    _rmtempdir(_dir)
Beispiel #6
0
def test_url_notfound_progressbar():
    _fn = _data['not_found']['url']
    res = download.file(_fn, progress=True)
    assert res is None
Beispiel #7
0
def test_url_progressbar():
    res = download.file(_data['success']['url'], progress=True)
    assert res
    assert os.path.isfile(res)
    assert res == _data['success']['name']
    os.remove(res)
Beispiel #8
0
def test_url_notfound():
    _fn = _data['not_found']['url']
    res = download.file(_fn)
    assert res is None
Beispiel #9
0
def test_url():
    res = download.file(_data['success']['url'])
    assert res
    assert os.path.isfile(res)
    assert res == _data['success']['name']
    os.remove(res)