@@ -56,22 +56,6 @@ def test_required_files(self):
56
56
self .assertRaises (ValueError , nightlight .get_required_nl_files ,
57
57
(- 90 , 90 ))
58
58
59
- def test_check_files_exist (self ):
60
- """Test check_nightlight_local_file_exists"""
61
- # If invalid directory is supplied it has to fail
62
- try :
63
- nightlight .check_nl_local_file_exists (
64
- np .ones (np .count_nonzero (BM_FILENAMES )), 'Invalid/path' )[0 ]
65
- raise Exception ("if the path is not valid, check_nl_local_file_exists should fail" )
66
- except ValueError :
67
- pass
68
- files_exist = nightlight .check_nl_local_file_exists (
69
- np .ones (np .count_nonzero (BM_FILENAMES )), SYSTEM_DIR )
70
- self .assertTrue (
71
- files_exist .sum () > 0 ,
72
- f'{ files_exist } { BM_FILENAMES } '
73
- )
74
-
75
59
def test_download_nightlight_files (self ):
76
60
"""Test check_nightlight_local_file_exists"""
77
61
# Not the same length of arguments
@@ -117,41 +101,7 @@ def test_get_required_nl_files(self):
117
101
req_files = nightlight .get_required_nl_files (bounds = bounds_c3 )
118
102
bool = np .array_equal (np .array ([0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 ]), req_files )
119
103
self .assertTrue (bool )
120
-
121
- def test_check_nl_local_file_exists (self ):
122
- """ Test that an array with the correct number of already existing files
123
- is produced, the LOGGER messages logged and the ValueError raised. """
124
-
125
- # check logger messages by giving a to short req_file
126
- with self .assertLogs ('climada.entity.exposures.litpop.nightlight' , level = 'WARNING' ) as cm :
127
- nightlight .check_nl_local_file_exists (required_files = np .array ([0 , 0 , 1 , 1 ]))
128
- self .assertIn ('The parameter \' required_files\' was too short and is ignored' ,
129
- cm .output [0 ])
130
-
131
- # check logger message: not all files are available
132
- with self .assertLogs ('climada.entity.exposures.litpop.nightlight' , level = 'DEBUG' ) as cm :
133
- nightlight .check_nl_local_file_exists ()
134
- self .assertIn ('Not all satellite files available. '
135
- f'Found 5 out of 8 required files in { Path (SYSTEM_DIR )} ' , cm .output [0 ])
136
-
137
- # check logger message: no files found in checkpath
138
- check_path = Path ('climada/entity/exposures' )
139
- with self .assertLogs ('climada.entity.exposures.litpop.nightlight' , level = 'INFO' ) as cm :
140
- # using a random path where no files are stored
141
- nightlight .check_nl_local_file_exists (check_path = check_path )
142
- self .assertIn (f'No satellite files found locally in { check_path } ' ,
143
- cm .output [0 ])
144
-
145
- # test raises with wrong path
146
- check_path = Path ('/random/wrong/path' )
147
- with self .assertRaises (ValueError ) as cm :
148
- nightlight .check_nl_local_file_exists (check_path = check_path )
149
- self .assertEqual (f'The given path does not exist: { check_path } ' ,
150
- str (cm .exception ))
151
-
152
- # test that files_exist is correct
153
- files_exist = nightlight .check_nl_local_file_exists ()
154
- self .assertEqual (int (sum (files_exist )), 5 )
104
+
155
105
156
106
# Execute Tests
157
107
if __name__ == "__main__" :
0 commit comments