Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MetObsAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MetObs
MetObsAPI
Commits
6bf472e1
Verified
Commit
6bf472e1
authored
1 year ago
by
David Hoese
Browse files
Options
Downloads
Patches
Plain Diff
Fix handling of only one wind component in API request
parent
752fb97e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
metobsapi/data_api.py
+2
-1
2 additions, 1 deletion
metobsapi/data_api.py
metobsapi/tests/test_data_api.py
+16
-0
16 additions, 0 deletions
metobsapi/tests/test_data_api.py
with
18 additions
and
1 deletion
metobsapi/data_api.py
+
2
−
1
View file @
6bf472e1
...
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
metobsapi/tests/test_data_api.py
+
16
−
0
View file @
6bf472e1
...
...
@@ -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
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment