Skip to content
Snippets Groups Projects
Verified Commit 6bf472e1 authored by David Hoese's avatar David Hoese
Browse files

Fix handling of only one wind component in API request

parent 752fb97e
No related branches found
No related tags found
No related merge requests found
......@@ -75,10 +75,11 @@ def handle_symbols(symbols: list[str]):
# detecting 'wind_direction', otherwise we don't know we need to readd it
influx_to_requested_symbols[f"{site}.{inst}.{influx_name}"] = symbol
influx_symbols.setdefault((site, inst), [])
if s == "wind_direction":
add_winds.add((site, inst))
continue
influx_symbols.setdefault((site, inst), []).append(influx_name)
influx_symbols[(site, inst)].append(influx_name)
# Add the symbols needed to compute the wind_speed and wind_direction
for site, inst in add_winds:
......
......@@ -402,6 +402,22 @@ def test_wind_speed_direction_json(symbols, client):
assert len(list(res["results"]["data"].keys())) == len(symbols)
@pytest.mark.usefixtures("influxdb_wind_fields_9_values")
def test_wind_direction_only_json(client):
symbols = ["wind_direction"]
symbol_param = ":".join(symbols)
site_inst_params = "&site=aoss&inst=tower"
res = client.get(f"/api/data.json?symbols={symbol_param}{site_inst_params}&begin=-00:10:00&order=column")
res = json.loads(res.data.decode())
assert res["code"] == 200
assert res["num_results"] == 9
for symbol_name in symbols:
assert symbol_name in res["results"]["data"]
assert not np.isnan(res["results"]["data"][symbol_name]).all()
assert len(list(res["results"]["data"].keys())) == len(symbols)
def test_one_symbol_two_insts_json_row(client, mock_influxdb_query):
fake_result = _fake_data(
"1m",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment