Skip to content

Commit 64f31a6

Browse files
committed
Update tests
1 parent f4cf5db commit 64f31a6

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

pvlib/iotools/pvgis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ def _parse_pvgis_hourly_csv(src, map_variables):
297297
# integer. It is necessary to convert to float, before converting to int
298298
data = data.astype(float).astype(dtype={'Int': 'int'})
299299
# Generate metadata dictionary containing description of parameters
300-
metadata['inputs']['descriptions'] = {}
300+
metadata['descriptions'] = {}
301301
for line in src.readlines():
302302
if ':' in line:
303-
metadata['inputs']['descriptions'][line.split(':')[0]] = line.split(':')[1].strip()
303+
metadata['descriptions'][line.split(':')[0]] = line.split(':')[1].strip()
304304
return data, metadata
305305

306306

tests/iotools/test_pvgis.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@
132132
'WS10m': {'description': '10-m total wind speed', 'units': 'm/s'}, # noqa: E501
133133
'Int': {'description': '1 means solar radiation values are reconstructed'}}}}} # noqa: E501
134134

135+
descriptions_csv = metadata_radiation_csv.copy()
136+
metadata_radiation_csv = {}
137+
metadata_radiation_csv['descriptions'] = descriptions_csv
138+
metadata_radiation_csv['inputs'] = inputs_radiation_csv
139+
140+
descriptions_json = metadata_pv_json['inputs']
141+
metadata_pv_json['inputs'] = inputs_pv_json
142+
metadata_pv_json['inputs']['descriptions'] = descriptions_json
143+
135144

136145
def generate_expected_dataframe(values, columns, index):
137146
"""Create dataframe from arrays of values, columns and index, in order to
@@ -175,25 +184,24 @@ def expected_pv_json_mapped():
175184
# Test read_pvgis_hourly function using two different files with different
176185
# input arguments (to test variable mapping and pvgis_format)
177186
# pytest request.getfixturevalue is used to simplify the input arguments
178-
@pytest.mark.parametrize('testfile,expected_name,metadata_exp,inputs_exp,map_variables,pvgis_format', [ # noqa: E501
187+
@pytest.mark.parametrize('testfile,expected_name,metadata_exp,map_variables,pvgis_format', [ # noqa: E501
179188
(testfile_radiation_csv, 'expected_radiation_csv', metadata_radiation_csv,
180-
inputs_radiation_csv, False, None),
189+
False, None),
181190
(testfile_radiation_csv, 'expected_radiation_csv_mapped',
182-
metadata_radiation_csv, inputs_radiation_csv, True, 'csv'),
183-
(testfile_pv_json, 'expected_pv_json', metadata_pv_json, inputs_pv_json,
191+
metadata_radiation_csv, True, 'csv'),
192+
(testfile_pv_json, 'expected_pv_json', metadata_pv_json,
184193
False, None),
185194
(testfile_pv_json, 'expected_pv_json_mapped', metadata_pv_json,
186-
inputs_pv_json, True, 'json')])
195+
True, 'json')])
187196
def test_read_pvgis_hourly(testfile, expected_name, metadata_exp,
188-
inputs_exp, map_variables, pvgis_format, request):
197+
map_variables, pvgis_format, request):
189198
# Get expected dataframe from fixture
190199
expected = request.getfixturevalue(expected_name)
191200
# Read data from file
192-
out, inputs, metadata = read_pvgis_hourly(
201+
out, metadata = read_pvgis_hourly(
193202
testfile, map_variables=map_variables, pvgis_format=pvgis_format)
194203
# Assert whether dataframe, metadata, and inputs are as expected
195204
assert_frame_equal(out, expected)
196-
assert inputs == inputs_exp
197205
assert metadata == metadata_exp
198206

199207

@@ -248,7 +256,7 @@ def test_get_pvgis_hourly(requests_mock, testfile, expected_name, args,
248256
# inputs are passing on correctly
249257
requests_mock.get(url_test, text=mock_response)
250258
# Make API call - an error is raised if requested URI does not match
251-
out, inputs, metadata = get_pvgis_hourly(
259+
out, metadata = get_pvgis_hourly(
252260
latitude=45, longitude=8, map_variables=map_variables, **args)
253261
# Get expected dataframe from fixture
254262
expected = request.getfixturevalue(expected_name)

0 commit comments

Comments
 (0)