def test_fetch_separate_filenames(): # Setup db = Database('sqlite:///') download_query = [ vso.attrs.Time('2012-08-05', '2012-08-05 00:00:05'), vso.attrs.Instrument('AIA') ] tmp_test_dir = os.path.join(sunpy.config.get('downloads', 'download_dir'), 'tmp_test_dir/') if not os.path.isdir(tmp_test_dir): os.mkdir(tmp_test_dir) path = tmp_test_dir + '{file}' db.fetch(*download_query, path=path) # Test assert len(db) == 4 dir_contents = os.listdir(tmp_test_dir) assert 'aia_lev1_335a_2012_08_05t00_00_02_62z_image_lev1.fits' in dir_contents assert 'aia_lev1_94a_2012_08_05t00_00_01_12z_image_lev1.fits' in dir_contents assert os.path.isfile( os.path.join(tmp_test_dir, 'aia_lev1_335a_2012_08_05t00_00_02_62z_image_lev1.fits')) assert os.path.isfile( os.path.join(tmp_test_dir, 'aia_lev1_94a_2012_08_05t00_00_01_12z_image_lev1.fits')) # Teardown shutil.rmtree(tmp_test_dir)
def test_fetch_separate_filenames(): # Setup db = Database('sqlite:///') download_query = [ vso.attrs.Time('2012-08-05', '2012-08-05 00:00:05'), vso.attrs.Instrument('AIA') ] tmp_test_dir = os.path.join( sunpy.config.get('downloads', 'download_dir'), 'tmp_test_dir/' ) if not os.path.isdir(tmp_test_dir): os.makedirs(tmp_test_dir) path = tmp_test_dir + '{file}' db.fetch(*download_query, path=path) # Test assert len(db) == 4 dir_contents = os.listdir(tmp_test_dir) assert 'aia_lev1_335a_2012_08_05t00_00_02_62z_image_lev1.fits' in dir_contents assert 'aia_lev1_94a_2012_08_05t00_00_01_12z_image_lev1.fits' in dir_contents assert os.path.isfile(os.path.join(tmp_test_dir, 'aia_lev1_335a_2012_08_05t00_00_02_62z_image_lev1.fits')) assert os.path.isfile(os.path.join(tmp_test_dir, 'aia_lev1_94a_2012_08_05t00_00_01_12z_image_lev1.fits')) # Teardown shutil.rmtree(tmp_test_dir)
def test_fetch_separate_filenames(): # Setup db = Database("sqlite:///") download_query = [vso.attrs.Time("2012-08-05", "2012-08-05 00:00:05"), vso.attrs.Instrument("AIA")] tmp_test_dir = os.path.join(sunpy.config.get("downloads", "download_dir"), "tmp_test_dir/") if not os.path.isdir(tmp_test_dir): os.mkdir(tmp_test_dir) path = tmp_test_dir + "{file}" db.fetch(*download_query, path=path) # Test assert len(db) == 8 dir_contents = os.listdir(tmp_test_dir) assert "aia_lev1_335a_2012_08_05t00_00_02_62z_image_lev1.fits" in dir_contents assert "aia_lev1_94a_2012_08_05t00_00_01_12z_image_lev1.fits" in dir_contents assert os.path.isfile(os.path.join(tmp_test_dir, "aia_lev1_335a_2012_08_05t00_00_02_62z_image_lev1.fits")) assert os.path.isfile(os.path.join(tmp_test_dir, "aia_lev1_94a_2012_08_05t00_00_01_12z_image_lev1.fits")) # Teardown shutil.rmtree(tmp_test_dir)