def test_download_mirror_list(self): tmp = tempfile.NamedTemporaryFile() tmp.close() progress = StringIO() Download(MirrorList.URL, tmp.name, progress=progress).run() self.assertEqual(progress.getvalue(), '[......................................................................]\n') with open(tmp.name, 'r') as f: content = f.read() self.assertTrue(content.startswith('# Sage Mirror List'))
def test_download_mirror_list(self): tmp = tempfile.NamedTemporaryFile() tmp.close() progress = StringIO() Download(MirrorList.URL, tmp.name, progress=progress).run() self.assertEqual( progress.getvalue(), '[......................................................................]\n' ) with open(tmp.name, 'r') as f: content = f.read() self.assertTrue(content.startswith('# Sage Mirror List'))
def test_error(self): URL = 'http://www.sagemath.org/sage_bootstrap/this_url_does_not_exist' progress = StringIO() download = Download(URL, progress=progress) log = CapturedLog() def action(): with log: download.run() self.assertRaises(IOError, action) self.assertIsNotFoundError(log.messages()) self.assertEqual(progress.getvalue(), '[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]\n')
def test_error(self): URL = 'http://files.sagemath.org/sage_bootstrap/this_url_does_not_exist' progress = StringIO() download = Download(URL, progress=progress) log = CapturedLog() def action(): with log: download.run() self.assertRaises(IOError, action) self.assertIsNotFoundError(log.messages()) self.assertEqual( progress.getvalue(), '[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]\n' )