@@ -184,6 +184,39 @@ def test_get_nsrdb_psm4_aggregated_errors(
184184 assert "OVER_RATE_LIMIT" not in str (excinfo .value )
185185
186186
187+ @pytest .mark .remote_data
188+ @pytest .mark .flaky (reruns = RERUNS , reruns_delay = RERUNS_DELAY )
189+ def test_get_nsrdb_psm4_polar_errors (nlr_api_key ):
190+ """Test get_nsrdb_psm4_polar() for bad input scenarios."""
191+ # Bad latitude/longitude -> Coordinates were outside the polar area.
192+ with pytest .raises (HTTPError ) as excinfo :
193+ psm4 .get_nsrdb_psm4_polar (55 , 0 , nlr_api_key , PVLIB_EMAIL , year = 2023 )
194+ # ensure the HTTPError caught isn't due to overuse of the API key
195+ assert "OVER_RATE_LIMIT" not in str (excinfo .value )
196+ # Bad API key -> HTTP 403 forbidden because api_key is rejected
197+ with pytest .raises (HTTPError ) as excinfo :
198+ psm4 .get_nsrdb_psm4_polar (
199+ LATITUDE_POLAR , LONGITUDE_POLAR , "bad_key" , PVLIB_EMAIL , year = 2023 )
200+ assert "OVER_RATE_LIMIT" not in str (excinfo .value )
201+
202+
203+ @pytest .mark .remote_data
204+ @pytest .mark .flaky (reruns = RERUNS , reruns_delay = RERUNS_DELAY )
205+ def test_get_nsrdb_psm4_polar_tmy_errors (nlr_api_key ):
206+ """Test get_nsrdb_psm4_polar_tmy() for bad input scenarios."""
207+ # Bad latitude/longitude -> Coordinates were outside the polar area.
208+ with pytest .raises (HTTPError ) as excinfo :
209+ psm4 .get_nsrdb_psm4_polar_tmy (
210+ 55 , 0 , nlr_api_key , PVLIB_EMAIL , year = "tmy-2023" )
211+ # ensure the HTTPError caught isn't due to overuse of the API key
212+ assert "OVER_RATE_LIMIT" not in str (excinfo .value )
213+ # Bad API key -> HTTP 403 forbidden because api_key is rejected
214+ with pytest .raises (HTTPError ) as excinfo :
215+ psm4 .get_nsrdb_psm4_polar_tmy (
216+ LATITUDE_POLAR , LONGITUDE_POLAR , "bad_key" , PVLIB_EMAIL ,
217+ year = "tmy-2023" )
218+ assert "OVER_RATE_LIMIT" not in str (excinfo .value )
219+
187220@pytest .fixture
188221def io_input (request ):
189222 """file-like object for read_nsrdb_psm4"""
0 commit comments