Example #1
0
 def test_dir_download(self):
     test_dir = os.path.join('data', 'dltest')
     shutil.rmtree(test_dir, ignore_errors=True)
     os.makedirs(test_dir)
     study = 'phs000722'
     fullname = study + ".v1.p1"
     dld = FileDownloader('ftp.ncbi.nlm.nih.gov')
     self.assertEqual(4, dld.download_dir(directory_template % dict(study=study, fullname=fullname), test_dir,
                      name_map=lambda s: s.replace('.xml', '.tst'), file_filtr=lambda s: 'data_dict' in s))
Example #2
0
 def test_dowload_single_file(self):
     study = 'phs001007'
     fullname = study + ".v1.p1"
     dld = FileDownloader('ftp.ncbi.nlm.nih.gov')
     self.assertEqual(open(os.path.join('data', 'phs001007.xml')).read(),
                      dld.download_file(single_file_template % dict(study=study, fullname=fullname)))