Skip to content

Commit 3777c77

Browse files
committed
Split test_get_nasa_power_all_variable_map_parameters_valid into two batches
VARIABLE_MAP now has 16 entries, exceeding NASA POWER's 15-parameter-per-request limit. Split the test into two batches of 8 instead of asserting the limit.
1 parent 879abc8 commit 3777c77

1 file changed

Lines changed: 18 additions & 19 deletions

File tree

tests/iotools/test_nasa_power.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,28 +108,27 @@ def test_get_nasa_power_all_variable_map_parameters_valid():
108108
live API. A typo or stale name (e.g. CLRSKY_DIFF vs CLRSKY_SFC_SW_DIFF)
109109
causes the API to return an HTTPError, which would fail this test.
110110
111-
NASA POWER allows max 15 parameters per request; VARIABLE_MAP fits within
112-
that. If the map grows past 15, split this test into batches.
111+
NASA POWER allows max 15 parameters per request; VARIABLE_MAP is split
112+
into two batches to stay within that limit.
113113
"""
114114
from pvlib.iotools.nasa_power import VARIABLE_MAP
115115
nasa_params = list(VARIABLE_MAP.keys())
116-
assert len(nasa_params) <= 15, (
117-
"VARIABLE_MAP exceeds NASA POWER's 15-parameter-per-request limit; "
118-
"split this test into batches."
119-
)
120-
121-
data, meta = pvlib.iotools.get_nasa_power(
122-
latitude=44.76,
123-
longitude=7.64,
124-
start='2025-02-02',
125-
end='2025-02-02',
126-
parameters=nasa_params,
127-
map_variables=False,
128-
)
129-
130-
# Every requested NASA parameter must come back as a column.
131-
missing = set(nasa_params) - set(data.columns)
132-
assert not missing, f"NASA POWER did not return: {sorted(missing)}"
116+
# Split into two batches; API limit is 15.
117+
half = (len(nasa_params) + 1) // 2
118+
batch1 = nasa_params[:half]
119+
batch2 = nasa_params[half:]
120+
121+
for batch in [batch1, batch2]:
122+
data, meta = pvlib.iotools.get_nasa_power(
123+
latitude=44.76,
124+
longitude=7.64,
125+
start='2025-02-02',
126+
end='2025-02-02',
127+
parameters=batch,
128+
map_variables=False,
129+
)
130+
missing = set(batch) - set(data.columns)
131+
assert not missing, f"NASA POWER did not return: {sorted(missing)}"
133132

134133

135134
@pytest.mark.remote_data

0 commit comments

Comments
 (0)