def test_download_file(self): fd, path = tempfile.mkstemp() os.close(fd) wagon._download_file(TEST_TAR, path) try: os.remove(path) except: pytest.xfail( "Failed to remove file, which means it was not downloaded")
def test_download_bad_url(self): if IS_PY3: with pytest.raises(ValueError) as ex: wagon._download_file('something', 'file') assert "unknown url type: 'something'" in str(ex.value) else: with pytest.raises(IOError) as ex: wagon._download_file('something', 'file') if wagon.IS_WIN: assert "cannot find the file specified: 'something'" \ in str(ex.value) else: assert "No such file or directory: 'something'" \ in str(ex.value)
def test_download_missing_path(self): with pytest.raises(IOError) as ex: wagon._download_file(TEST_TAR, 'x/file') assert 'No such file or directory' in str(ex.value)
def test_download_file_missing(self): with pytest.raises(wagon.WagonError) as ex: wagon._download_file('http://www.google.com/x.tar.gz', 'file') assert "Failed to download file" in str(ex)
def test_download_no_permissions(self): with pytest.raises(IOError) as ex: wagon._download_file(TEST_TAR, '/file') assert 'Permission denied' in str(ex)