@@ -168,6 +168,46 @@ def test_get_countries_per_region(self):
168168 self .assertListEqual (out [2 ], [124 , 840 ])
169169 self .assertListEqual (out [3 ], ["CAN" , "USA" ])
170170
171+ def test_get_region_per_countries (self ):
172+ """Test static get_regions_per_countries()"""
173+ ifs = ImpfSetTropCyclone ()
174+ out = ifs .get_regions_per_countries (countries = ["CHE" ], code_type = "ISO3A" )
175+ self .assertEqual (out [0 ][0 ], 10 )
176+ self .assertEqual (out [1 ][0 ], "ROW" )
177+ self .assertEqual (out [2 ][0 ], "Rest of The World" )
178+ out = ifs .get_regions_per_countries (countries = [756 ], code_type = "ISO3N" )
179+ self .assertEqual (out [0 ][0 ], 10 )
180+ self .assertEqual (out [1 ][0 ], "ROW" )
181+ self .assertEqual (out [2 ][0 ], "Rest of The World" )
182+ with self .assertRaises (ValueError ) as context :
183+ ImpfSetTropCyclone .get_regions_per_countries (
184+ countries = ["SWE" ], code_type = "invalid_code"
185+ )
186+ self .assertEqual (
187+ str (context .exception ), "code_type must be either 'iso3a' or 'iso3n'"
188+ )
189+ with self .assertRaises (ValueError ) as context :
190+ ImpfSetTropCyclone .get_regions_per_countries (
191+ countries = ["SWE" , 840 ], code_type = "ISO3A"
192+ )
193+ self .assertEqual (
194+ str (context .exception ), "All elements in the list must be of the same type."
195+ )
196+ with self .assertRaises (ValueError ) as context :
197+ ImpfSetTropCyclone .get_regions_per_countries (
198+ countries = [840 , 124 ], code_type = "ISO3A"
199+ )
200+ self .assertEqual (
201+ str (context .exception ), "ISO3A code type cannot have integer values."
202+ )
203+ with self .assertRaises (ValueError ) as context :
204+ ImpfSetTropCyclone .get_regions_per_countries (
205+ countries = ["MEX" ], code_type = "ISO3N"
206+ )
207+ self .assertEqual (
208+ str (context .exception ), "ISO3N code type cannot have string values."
209+ )
210+
171211
172212# Execute Tests
173213if __name__ == "__main__" :
0 commit comments