Skip to content

Commit

Permalink
Fix tests setting metric to False in cli and restapi
Browse files Browse the repository at this point in the history
Add some docstrings
  • Loading branch information
gutzbenj committed Apr 23, 2021
1 parent 16c300c commit 7e60be7
Show file tree
Hide file tree
Showing 19 changed files with 143 additions and 129 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
Development
***********

...
- Add origin and metric unit mappings to services
- Use argument "metric" in request classes to convert origin units to metric, set to default

0.17.0 (08.04.2021)
*******************
Expand Down
45 changes: 23 additions & 22 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ importlib_metadata = { version = "^1.7.0", python = "<3.8" }
# Optional dependencies aka. "extras"
openpyxl = { version = "^3.0.7", optional = true }
pyarrow = { version = "^3.0.0", optional = true, markers = "sys_platform != 'darwin' or (sys_platform == 'darwin' and platform_machine != 'arm64')"} # not supported through h5py
duckdb = { version = "^0.2.3", optional = true }
duckdb = { version = "^0.2.3", optional = true, allow-prereleases = true }
influxdb = { version = "^5.3.0", optional = true }
sqlalchemy = { version = "^1.3", optional = true }
crate = { version = "^0.25.0", optional = true, extras = ["sqlalchemy"] }
Expand All @@ -111,7 +111,7 @@ psycopg2-binary = { version = "^2.8.6", optional = true }
# HTTP REST API service
fastapi = { version = "^0.61.1", optional = true }
uvicorn = { version = "^0.13.3", optional = true }
wradlib = { version = "^1.9.0", optional = true, markers = "sys_platform != 'darwin' or (sys_platform == 'darwin' and platform_machine != 'arm64')"} # not supported through h5py
wradlib = { version = "^1.9.0", optional = true }

# Explorer UI service
plotly = { version = "^4.14.3", optional = true }
Expand All @@ -130,7 +130,7 @@ ipython-genutils = { version = "^0.2.0", optional = true }
requests-ftp = "^0.3.1"
zarr = {version = "^2.7.0", optional = true, markers = "sys_platform != 'darwin' or (sys_platform == 'darwin' and platform_machine != 'arm64')"} # not supported through numcodecs
xarray = {version = "^0.17.0", optional = true}
h5netcdf = {version = "^0.10.0", markers = "sys_platform != 'darwin' or (sys_platform == 'darwin' and platform_machine != 'arm64')"}
h5netcdf = "^0.10.0"
measurement = "^3.2.0"
rapidfuzz = "^1.4.1"
Pint = "^0.17"
Expand All @@ -153,7 +153,7 @@ pytest-dictsdiff = "^0.5.8"
mock = "^4.0.2"
surrogate = "^0.1"
pybufrkit = "^0.2.17"
h5py = {version = "^3.1.0", markers = "sys_platform != 'darwin' or (sys_platform == 'darwin' and platform_machine != 'arm64')"}
h5py = "^3.1.0"
freezegun = "^1.1.0"

poethepoet = "^0.9.0"
Expand Down Expand Up @@ -219,7 +219,7 @@ pyflakes = ["-F401"]
flake8-bandit = ["-S101"]
[tool.flakehell.exceptions."tests/provider/dwd/radar/test_index.py"]
pycodestyle = ["-E501", "-B950"]
[tool.flakehell.exceptions."tests/provider/dwd/observations/util/test_parameter.py"]
[tool.flakehell.exceptions."tests/provider/dwd/observation/util/test_parameter.py"]
pycodestyle = ["-E501", "-B950"]

[tool.flakehell.exceptions."wetterdienst/ui/cli.py"]
Expand Down Expand Up @@ -273,7 +273,7 @@ show_missing = true
fail_under = 0
omit = [
"tests/*",
"wetterdienst/dwd/radar/cli.py",
"wetterdienst/provider/dwd/radar/cli.py",
]

[build-system]
Expand Down
4 changes: 2 additions & 2 deletions tests/provider/dwd/observation/test_api_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def test_dwd_observation_data_result_tabular():
end_date="1934-01-01", # few days after official start,
tidy=False,
humanize=False,
metric=False
metric=False,
).filter_by_station_id(
station_id=[1048],
)
Expand Down Expand Up @@ -390,7 +390,7 @@ def test_dwd_observation_data_result_tidy():
end_date="1934-01-01", # few days after official start,
tidy=True,
humanize=False,
metric=False
metric=False,
).filter_by_station_id(
station_id=(1048,),
)
Expand Down
16 changes: 11 additions & 5 deletions tests/provider/dwd/observation/test_api_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@


def test_dwd_observation_metadata_discover_parameters():
parameters = DwdObservationRequest.discover(filter_="minute_1", flatten=True, metric=True)
parameters = DwdObservationRequest.discover(filter_="minute_1", flatten=True)

assert (
json.dumps(
{
"minute_1": {
"precipitation_height": "kg / m ** 2",
"precipitation_height_droplet": "kg / m ** 2",
"precipitation_height_rocker": "kg / m ** 2",
"precipitation_form": "-"
"precipitation_height": {"origin": "mm", "metric": "kg / m ** 2"},
"precipitation_height_droplet": {
"origin": "mm",
"metric": "kg / m ** 2",
},
"precipitation_height_rocker": {
"origin": "mm",
"metric": "kg / m ** 2",
},
"precipitation_form": {"origin": "-", "metric": "-"},
}
},
indent=4,
Expand Down
11 changes: 9 additions & 2 deletions tests/provider/dwd/observation/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def test_export_spreadsheet(tmpdir_factory):
start_date="2019",
end_date="2020",
tidy=False,
metric=False
metric=False,
).filter_by_station_id(
station_id=[1048],
)
Expand Down Expand Up @@ -330,6 +330,7 @@ def test_export_parquet(tmpdir_factory):
start_date="2019",
end_date="2020",
tidy=False,
metric=False,
).filter_by_station_id(
station_id=[1048],
)
Expand Down Expand Up @@ -397,6 +398,7 @@ def test_export_zarr(tmpdir_factory):
start_date="2019",
end_date="2020",
tidy=False,
metric=False,
).filter_by_station_id(
station_id=[1048],
)
Expand Down Expand Up @@ -464,6 +466,7 @@ def test_export_feather(tmpdir_factory):
start_date="2019",
end_date="2020",
tidy=False,
metric=False,
).filter_by_station_id(
station_id=[1048],
)
Expand Down Expand Up @@ -528,7 +531,7 @@ def test_export_sqlite(tmpdir_factory):
start_date="2019",
end_date="2020",
tidy=False,
metric=False
metric=False,
).filter_by_station_id(
station_id=[1048],
)
Expand Down Expand Up @@ -594,6 +597,7 @@ def test_export_cratedb():
parameter=DwdObservationDataset.CLIMATE_SUMMARY,
resolution=DwdObservationResolution.DAILY,
period=DwdObservationPeriod.RECENT,
metric=False,
).filter_by_station_id(
station_id=[1048],
)
Expand Down Expand Up @@ -623,6 +627,7 @@ def test_export_duckdb():
parameter=DwdObservationDataset.CLIMATE_SUMMARY,
resolution=DwdObservationResolution.DAILY,
period=DwdObservationPeriod.RECENT,
metric=False,
).filter_by_station_id(station_id=[1048])

mock_connection = mock.MagicMock()
Expand All @@ -649,6 +654,7 @@ def test_export_influxdb_tabular():
resolution=DwdObservationResolution.DAILY,
period=DwdObservationPeriod.RECENT,
tidy=False,
metric=False,
).filter_by_station_id(station_id=[1048])

mock_client = mock.MagicMock()
Expand Down Expand Up @@ -681,6 +687,7 @@ def test_export_influxdb_tidy():
resolution=DwdObservationResolution.DAILY,
period=DwdObservationPeriod.RECENT,
tidy=True,
metric=False,
).filter_by_station_id(station_id=[1048])

mock_client = mock.MagicMock()
Expand Down
8 changes: 1 addition & 7 deletions tests/provider/dwd/radar/test_api_current.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018-2021, earthobservations developers.
# Distributed under the MIT License. See LICENSE for more info.
import h5py
import pytest

from tests import mac_arm64, mac_arm64_unsupported
from wetterdienst.provider.dwd.radar import (
DwdRadarDataFormat,
DwdRadarDataSubset,
Expand All @@ -14,11 +14,7 @@
)
from wetterdienst.provider.dwd.radar.sites import DwdRadarSite

if not mac_arm64:
import h5py


@mac_arm64_unsupported
@pytest.mark.remote
def test_radar_request_site_current_sweep_pcp_v_hdf5():
"""
Expand Down Expand Up @@ -62,7 +58,6 @@ def test_radar_request_site_current_sweep_pcp_v_hdf5():
assert shape == (360, 600) or shape == (361, 600)


@mac_arm64_unsupported
@pytest.mark.remote
def test_radar_request_site_current_sweep_vol_v_hdf5_full():
"""
Expand Down Expand Up @@ -106,7 +101,6 @@ def test_radar_request_site_current_sweep_vol_v_hdf5_full():
assert shape == (360, 180) or shape == (360, 720)


@mac_arm64_unsupported
@pytest.mark.remote
def test_radar_request_site_current_sweep_vol_v_hdf5_single():
"""
Expand Down
7 changes: 1 addition & 6 deletions tests/provider/dwd/radar/test_api_historic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from io import BytesIO
from pathlib import Path

import h5py
import pybufrkit
import pytest

from tests import mac_arm64, mac_arm64_unsupported
from tests.provider.dwd.radar import (
station_reference_pattern_de,
station_reference_pattern_sorted,
Expand All @@ -26,9 +26,6 @@
from wetterdienst.provider.dwd.radar.sites import DwdRadarSite
from wetterdienst.util.datetime import round_minutes

if not mac_arm64:
import h5py

HERE = Path(__file__).parent


Expand Down Expand Up @@ -639,7 +636,6 @@ def test_radar_request_site_historic_sweep_vol_v_bufr_timerange():
# TODO: Verify data.


@mac_arm64_unsupported
@pytest.mark.remote
def test_radar_request_site_historic_sweep_pcp_v_hdf5_yesterday():
"""
Expand Down Expand Up @@ -725,7 +721,6 @@ def test_radar_request_site_historic_sweep_pcp_v_hdf5_timerange():
# TODO: Verify data.


@mac_arm64_unsupported
@pytest.mark.remote
def test_radar_request_site_historic_sweep_vol_v_hdf5_yesterday():
"""
Expand Down
7 changes: 1 addition & 6 deletions tests/provider/dwd/radar/test_api_most_recent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Distributed under the MIT License. See LICENSE for more info.
import re

import h5py
import pytest

from tests import mac_arm64, mac_arm64_unsupported
from tests.provider.dwd.radar import station_reference_pattern_unsorted
from wetterdienst.provider.dwd.radar import DwdRadarParameter, DwdRadarValues
from wetterdienst.provider.dwd.radar.metadata import (
Expand All @@ -16,11 +16,7 @@
)
from wetterdienst.provider.dwd.radar.sites import DwdRadarSite

if not mac_arm64:
import h5py


@mac_arm64_unsupported
@pytest.mark.remote
def test_radar_request_site_most_recent_sweep_pcp_v_hdf5():
"""
Expand Down Expand Up @@ -65,7 +61,6 @@ def test_radar_request_site_most_recent_sweep_pcp_v_hdf5():
assert hdf["/dataset1/data1/data"].shape == (360, 600)


@mac_arm64_unsupported
@pytest.mark.remote
def test_radar_request_site_most_recent_sweep_vol_v_hdf5():
"""
Expand Down
7 changes: 1 addition & 6 deletions tests/provider/dwd/radar/test_api_recent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@
# Distributed under the MIT License. See LICENSE for more info.
from datetime import datetime, timedelta

import h5py
import pytest

from tests import mac_arm64, mac_arm64_unsupported
from wetterdienst.provider.dwd.radar import DwdRadarParameter, DwdRadarValues
from wetterdienst.provider.dwd.radar.metadata import (
DwdRadarDataFormat,
DwdRadarDataSubset,
)
from wetterdienst.provider.dwd.radar.sites import DwdRadarSite

if not mac_arm64:
import h5py


@mac_arm64_unsupported
@pytest.mark.remote
def test_radar_request_site_recent_sweep_pcp_v_hdf5():
"""
Expand Down Expand Up @@ -62,7 +58,6 @@ def test_radar_request_site_recent_sweep_pcp_v_hdf5():
assert hdf["/dataset1/data1/data"].shape == (360, 600)


@mac_arm64_unsupported
@pytest.mark.remote
def test_radar_request_site_recent_sweep_vol_v_hdf5():
"""
Expand Down
3 changes: 1 addition & 2 deletions tests/provider/dwd/radar/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ def test_radar_fileindex_radolan_cdc_5minutes():
)

urls = file_index[DwdColumns.FILENAME.value].tolist()
for url in urls:
print(url)

assert all(
PurePath(url).match(
"*/climate_environment/CDC/grids_germany/5_minutes/radolan/reproc/2017_002/bin/*/YW2017*.tar"
Expand Down

0 comments on commit 7e60be7

Please sign in to comment.