2020"""
2121
2222from pathlib import Path
23+ from sys import dont_write_bytecode
2324import pandas as pd
2425import unittest
25- import urllib
2626import xmlrunner
2727import datetime as dt
2828
29- # solve version problem in pandas-datareader-0.6.0. see:
30- # https://stackoverflow.com/questions/50394873/import-pandas-datareader-gives-
31- # importerror-cannot-import-name-is-list-like
32- pd .core .common .is_list_like = pd .api .types .is_list_like
29+ import numpy as np
3330from pandas_datareader import wb
3431
35- from climada .entity .exposures .nightlight import NOAA_SITE , NASA_SITE , BM_FILENAMES
32+ from climada import CONFIG
33+ from climada .entity .exposures .litpop .nightlight import BM_FILENAMES , download_nl_files
3634from climada .hazard .tc_tracks import IBTRACS_URL , IBTRACS_FILE
3735from climada .hazard .tc_tracks_forecast import TCForecast
3836from climada .util .finance import WORLD_BANK_WEALTH_ACC , WORLD_BANK_INC_GRP
@@ -46,14 +44,20 @@ class TestDataAvail(unittest.TestCase):
4644
4745 def test_noaa_nl_pass (self ):
4846 """Test NOAA nightlights used in BlackMarble."""
49- file_down = download_file (NOAA_SITE + ' F101992.v4.tar' )
47+ file_down = download_file (f' { CONFIG . exposures . litpop . nightlights . noaa_url . str () } / F101992.v4.tar' )
5048 Path (file_down ).unlink ()
5149
5250 def test_nasa_nl_pass (self ):
5351 """Test NASA nightlights used in BlackMarble and LitPop."""
54- url = NASA_SITE + BM_FILENAMES [0 ]
55- file_down = download_file (url .replace ('*' , str (2016 )))
56- Path (file_down ).unlink ()
52+ req_files = np .zeros (len (BM_FILENAMES ))
53+ req_files [0 ] = 1
54+ year = 2016
55+ dwnl_path = CONFIG .local_data .save_dir .dir ()
56+ dwnl_file = dwnl_path .joinpath (BM_FILENAMES [0 ] % year )
57+ self .assertFalse (dwnl_file .is_file ())
58+ download_nl_files (req_files = req_files , dwnl_path = dwnl_path , year = year )
59+ self .assertTrue (dwnl_file .is_file ())
60+ dwnl_file .unlink ()
5761
5862 def test_wb_wealth_pass (self ):
5963 """Test world bank's wealth data"""
0 commit comments