Skip to content

Commit

Permalink
Cleanup tests for cli and restapi
Browse files Browse the repository at this point in the history
  • Loading branch information
gutzbenj committed Oct 21, 2023
1 parent 12156af commit 473b469
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 109 deletions.
6 changes: 4 additions & 2 deletions tests/core/timeseries/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import sqlite3
from unittest import mock

import duckdb
import openpyxl
import polars as pl
import pytest
from surrogate import surrogate
Expand Down Expand Up @@ -248,6 +246,8 @@ def test_export_unknown(default_settings):
@pytest.mark.remote
def test_export_spreadsheet(tmp_path, settings_si_false_wide_shape):
"""Test export of DataFrame to spreadsheet"""
import openpyxl

# 1. Request data and save to .xlsx file.
request = DwdObservationRequest(
parameter=DwdObservationDataset.CLIMATE_SUMMARY,
Expand Down Expand Up @@ -598,6 +598,8 @@ def test_export_cratedb(
@pytest.mark.remote
def test_export_duckdb(settings_si_false, tmp_path):
"""Test export of DataFrame to duckdb"""
import duckdb

request = DwdObservationRequest(
parameter=DwdObservationDataset.CLIMATE_SUMMARY,
resolution=DwdObservationResolution.DAILY,
Expand Down
20 changes: 9 additions & 11 deletions tests/ui/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import polars as pl
import pytest
from click.testing import CliRunner
from dirty_equals import IsDict, IsFloat, IsStr
from dirty_equals import IsFloat, IsStr

from tests.conftest import IS_WINDOWS
from wetterdienst.ui.cli import cli
Expand Down Expand Up @@ -346,16 +346,14 @@ def test_cli_values_json_multiple_datasets(capsys, caplog):
)
response = json.loads(result.stdout)
item = response[12]
assert item == IsDict(
{
"station_id": "01048",
"dataset": "climate_summary",
"parameter": "wind_gust_max",
"date": "2020-06-30T00:00:00+00:00",
"value": 15.3,
"quality": 10.0,
}
)
assert item == {
"station_id": "01048",
"dataset": "climate_summary",
"parameter": "wind_gust_max",
"date": "2020-06-30T00:00:00+00:00",
"value": 15.3,
"quality": 10.0,
}


@pytest.mark.remote
Expand Down
Loading

0 comments on commit 473b469

Please sign in to comment.