@@ -279,6 +279,13 @@ def test_get_pvgis_hourly_bad_outputformat(requests_mock):
279279 get_pvgis_hourly (latitude = 45 , longitude = 8 , outputformat = 'basic' )
280280
281281
282+ def test_get_pvgis_tmy_basic_outputformat ():
283+ # Test if a ValueError is raised if an unsupported outputformat is used
284+ # E.g. 'basic' is a valid PVGIS format, but is not supported by pvlib
285+ with pytest .raises (ValueError ):
286+ get_pvgis_tmy (latitude = 45 , longitude = 8 , outputformat = 'basic' )
287+
288+
282289url_additional_inputs = 'https://re.jrc.ec.europa.eu/api/seriescalc?lat=55.6814&lon=12.5758&outputformat=csv&angle=0&aspect=0&pvcalculation=1&pvtechchoice=crystSi&mountingplace=free&trackingtype=0&components=1&usehorizon=1&optimalangles=1&optimalinclination=0&loss=2&userhorizon=10%2C15%2C20%2C10&peakpower=5' # noqa: E501
283290
284291
@@ -427,21 +434,6 @@ def test_get_pvgis_tmy_kwargs(userhorizon_expected):
427434 assert inputs ['meteo_data' ]['year_max' ] == 2016
428435
429436
430- @pytest .mark .remote_data
431- @pytest .mark .flaky (reruns = RERUNS , reruns_delay = RERUNS_DELAY )
432- def test_get_pvgis_tmy_basic (expected , meta_expected ):
433- pvgis_data = get_pvgis_tmy (45 , 8 , outputformat = 'basic' ,
434- map_variables = False )
435- _compare_pvgis_tmy_basic (expected , meta_expected , pvgis_data )
436-
437-
438- def _compare_pvgis_tmy_basic (expected , meta_expected , pvgis_data ):
439- data , _ , _ , _ = pvgis_data
440- # check each column of output separately
441- for outvar in meta_expected ['outputs' ]['tmy_hourly' ]['variables' ].keys ():
442- assert np .allclose (data [outvar ], expected [outvar ])
443-
444-
445437@pytest .mark .remote_data
446438@pytest .mark .flaky (reruns = RERUNS , reruns_delay = RERUNS_DELAY )
447439def test_get_pvgis_tmy_coerce_year ():
@@ -630,23 +622,6 @@ def test_read_pvgis_tmy_csv(expected, month_year_expected, inputs_expected,
630622 meta_expected , csv_meta , pvgis_data )
631623
632624
633- def test_read_pvgis_tmy_basic (expected , meta_expected ):
634- fn = TESTS_DATA_DIR / 'tmy_45.000_8.000_2005_2023.txt'
635- # XXX: can't infer outputformat from file extensions for basic
636- with pytest .raises (ValueError , match = "pvgis format 'txt' was unknown" ):
637- read_pvgis_tmy (fn , map_variables = False )
638- # explicit pvgis outputformat
639- pvgis_data = read_pvgis_tmy (fn , pvgis_format = 'basic' , map_variables = False )
640- _compare_pvgis_tmy_basic (expected , meta_expected , pvgis_data )
641- with fn .open ('rb' ) as fbuf :
642- pvgis_data = read_pvgis_tmy (fbuf , pvgis_format = 'basic' ,
643- map_variables = False )
644- _compare_pvgis_tmy_basic (expected , meta_expected , pvgis_data )
645- # file buffer raises TypeError if passed to pathlib.Path()
646- with pytest .raises (TypeError ):
647- read_pvgis_tmy (fbuf , map_variables = False )
648-
649-
650625def test_read_pvgis_tmy_exception ():
651626 bad_outputformat = 'bad'
652627 err_msg = f"pvgis format '{ bad_outputformat :s} ' was unknown"
0 commit comments