def test_get_latest_version_connection_error(self, urlopen): # given urlopen.side_effect = IOError("oh no!") # when download = Downloader.get_latest_version() # then self.assertFalse(download)
def test_download(self, urlretrieve, get_home_dir, os_path_join): # given callback = lambda x, y, z: x urlretrieve.return_value = StringIO("a file") get_home_dir.return_value = "/home/user/dir" os_path_join.return_value = get_home_dir() + "/tmp-file.zip" # when result = Downloader.download(self.download, callback) # then url = 'http://whyteboard.googlecode.com/files/whyteboard-0.4.tar.gz' urlretrieve.assert_called_with(url, '/home/user/dir/tmp-file.zip', callback)
def test_get_latest_version(self, urlopen): # given urlopen.return_value = dummy_update_file() # when download = Downloader.get_latest_version() # then self.assertEqual("0.4", download.version) self.assertEqual("whyteboard-0.4.zip", download.executable_filename) self.assertEqual("5587799", download.executable_size) self.assertEqual("whyteboard-0.4.tar.gz", download.source_filename) self.assertEqual("372110", download.source_size)