def test_damir(self): temp = get_temp_folder(__file__, "temp_damir") res = download_data("A201612_small.csv.gz", whereTo=temp) self.assertEqual(len(res), 1) checks = [ os.path.join(temp, _) for _ in ["A201612_small.csv", "A201612_small.csv.gz"] ] self.assertExists(checks[0]) self.assertExists(checks[1])
def test_download_data2(self): fold = get_temp_folder(__file__, "temp_download_data2") exp = ["VOEUX01.txt", "voeux.zip"] res = download_data(["voeux.zip"], website=["xd"], whereTo=fold, timeout=10) self.assertEqual(len(res), 14) self.assertIn("VOEUX01.txt", res[0]) for f in exp: g = os.path.join(fold, f) self.assertExists(g)
def test_gz(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") fold = os.path.join(os.path.abspath(os.path.split(__file__)[0]), "temp_stand") if not os.path.exists(fold): os.mkdir(fold) for f in os.listdir(fold): if os.path.isfile(f): os.remove(os.path.join(fold, f)) files = download_data("facebook_combined.txt.gz", website="http://snap.stanford.edu/data/", fLOG=fLOG, whereTo=fold) fLOG(files)
def test_tar_gz(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") fold = os.path.join(os.path.abspath(os.path.split(__file__)[0]), "temp_stand") if not os.path.exists(fold): os.mkdir(fold) for f in os.listdir(fold): if os.path.isfile(f): os.remove(os.path.join(fold, f)) files = download_data("facebook.tar.gz", website="http://snap.stanford.edu/data/", fLOG=fLOG, whereTo=fold) fLOG(files) sh = [g for g in files if g.endswith("3980.egofeat")] assert len(files) > 0 assert len(sh) == 1
def test_gz(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") fold = os.path.join( os.path.abspath( os.path.split(__file__)[0]), "temp_stand") if not os.path.exists(fold): os.mkdir(fold) for f in os.listdir(fold): if os.path.isfile(f): os.remove(os.path.join(fold, f)) files = download_data( "facebook_combined.txt.gz", website="xd", fLOG=fLOG, whereTo=fold) fLOG(files)
def test_import_one(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") fold = os.path.join(os.path.abspath(os.path.split(__file__)[0]), "temp_http") if not os.path.exists(fold): os.mkdir(fold) exp = ["VOEUX01.txt", "voeux.zip"] for f in exp: g = os.path.join(fold, f) if os.path.exists(g): os.remove(g) one = "voeux.zip" res = download_data(one, website="xd", whereTo=fold, fLOG=fLOG) fLOG(len(res), res) assert len(res) == 14 assert "VOEUX01.txt" in res[0] for f in exp: g = os.path.join(fold, f) assert os.path.exists(g)
def test_tar_gz(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") fold = os.path.join( os.path.abspath( os.path.split(__file__)[0]), "temp_stand") if not os.path.exists(fold): os.mkdir(fold) for f in os.listdir(fold): if os.path.isfile(f): os.remove(os.path.join(fold, f)) files = download_data( "facebook.tar.gz", website="xd", fLOG=fLOG, whereTo=fold) fLOG(files) sh = [g for g in files if g.endswith("3980.egofeat")] assert len(files) > 0 assert len(sh) == 1
def test_import_one(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") fold = os.path.join( os.path.abspath( os.path.split(__file__)[0]), "temp_http") if not os.path.exists(fold): os.mkdir(fold) exp = ["VOEUX01.txt", "voeux.zip"] for f in exp: g = os.path.join(fold, f) if os.path.exists(g): os.remove(g) one = "voeux.zip" res = download_data(one, website="xd", whereTo=fold, fLOG=fLOG) fLOG(len(res), res) assert len(res) == 14 assert "VOEUX01.txt" in res[0] for f in exp: g = os.path.join(fold, f) assert os.path.exists(g)
def test_download_data_failures(self): fold = get_temp_folder(__file__, "temp_download_data_failures") one = "voeux2.zip" self.assertRaise( lambda: download_data(one, website="xd", whereTo=fold, timeout=10), DownloadDataException)
def test_gz(self): fold = get_temp_folder(__file__, "temp_gz") files = download_data("facebook_combined.txt.gz", website="xd", whereTo=fold) self.assertNotEmpty(files)
def test_tar_gz(self): fold = get_temp_folder(__file__, "temp_tar_gz") files = download_data("facebook.tar.gz", website="xd", whereTo=fold) sh = [g for g in files if g.endswith("3980.egofeat")] self.assertNotEmpty(files) self.assertEqual(len(sh), 1)