Exemplo n.º 1
0
 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")
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 def test_download_no_permissions(self):
     with pytest.raises(IOError) as ex:
         wagon._download_file(TEST_TAR, '/file')
     assert 'Permission denied' in str(ex)