Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gutzbenj committed Jun 2, 2021
1 parent 4b92b53 commit 7074926
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
8 changes: 4 additions & 4 deletions tests/ui/test_cli.py
Expand Up @@ -277,8 +277,8 @@ def test_cli_stations_excel(
provider, kind, setting, station_id, station_name, tmpdir_factory
):

filename = tmpdir_factory.mktemp("data").join("stations.xlsx")
# filename = "stations.xlsx"
# filename = tmpdir_factory.mktemp("data").join("stations.xlsx")
filename = "stations.xlsx"

_ = invoke_wetterdienst_stations_export(
provider=provider,
Expand Down Expand Up @@ -384,8 +384,8 @@ def test_cli_values_excel(
provider, kind, setting, station_id, station_name, tmpdir_factory
):

filename = tmpdir_factory.mktemp("data").join("values.xlsx")
# filename = "values.xlsx"
# filename = tmpdir_factory.mktemp("data").join("values.xlsx")
filename = "values.xlsx"

_ = invoke_wetterdienst_values_export(
provider=provider,
Expand Down
20 changes: 8 additions & 12 deletions wetterdienst/ui/cli.py
Expand Up @@ -21,18 +21,8 @@

log = logging.getLogger(__name__)


appname = f"{__appname__} {__version__}"

# def output(thing):
# for item in thing:
# if item:
# if hasattr(item, "value"):
# value = item.value
# else:
# value = item
# print("-", value)

provider_opt = cloup.option_group(
"Provider",
click.option(
Expand All @@ -41,6 +31,7 @@
required=True,
),
)

kind_opt = cloup.option_group(
"Kind",
click.option(
Expand All @@ -52,11 +43,14 @@
required=True,
),
)

debug_opt = click.option("--debug", is_flag=True)


def get_api(provider: str, kind: str):
"""
Function to get API for provider and kind, if non found click.Abort()
is casted with the error message
:param provider:
:param kind:
Expand All @@ -72,6 +66,7 @@ def get_api(provider: str, kind: str):

def station_options(command):
"""
Station options for cli, which can be used for stations and values endpoint
:param command:
:return:
Expand Down Expand Up @@ -401,7 +396,7 @@ def about():
)
@cloup.option("--filter", "filter_", type=click.STRING, default=False)
@debug_opt
def coverage(provider, kind, filter_, debug, **kwargs):
def coverage(provider, kind, filter_, debug):
set_logging_level(debug)

if not provider or not kind:
Expand Down Expand Up @@ -471,6 +466,7 @@ def fields(provider, kind, dataset, resolution, period, language, **kwargs):
If("coordinates", then=RequireExactly(1), else_=accept_none),
["rank", "distance"],
)
@cloup.option("--pretty", is_flag=True)
@debug_opt
def stations(
provider: str,
Expand Down Expand Up @@ -536,7 +532,7 @@ def stations(
@provider_opt
@kind_opt
@station_options
@cloup.option("--date", type=click.STRING, required=True)
@cloup.option("--date", type=click.STRING)
@cloup.option("--tidy", is_flag=True)
@cloup.option("--sql-values", type=click.STRING)
@cloup.option_group(
Expand Down
15 changes: 9 additions & 6 deletions wetterdienst/ui/restapi.py
Expand Up @@ -230,7 +230,7 @@ def values(
bbox: str = Query(default=None),
sql: str = Query(default=None),
sql_values: str = Query(alias="sql-values", default=None),
# fmt: str = Query(alias="format", default="json"),
# fmt: str = Query(alias="format", default="json"), missing geojson support
tidy: bool = Query(default=True),
si_units: bool = Query(alias="si-units", default=True),
pretty: bool = Query(default=False),
Expand Down Expand Up @@ -330,11 +330,6 @@ def values(

output = values_.to_dict()

# if fmt == "json":
# output = stations_.to_dict()
# elif fmt == "geojson":
# output = stations_._to_ogc_feature_collection()

output = make_json_response(output, api.provider)

output = json.dumps(output, indent=indent, ensure_ascii=False)
Expand All @@ -343,6 +338,14 @@ def values(


def make_json_response(data, provider):
"""
Function to add wetterdienst metadata information, citation, etc as well as
information about the data provider
:param data:
:param provider:
:return:
"""
name_local, name_english, country, copyright_, url = provider.value

response = {
Expand Down

0 comments on commit 7074926

Please sign in to comment.