Skip to content

Commit

Permalink
Merge main + update test warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolai committed Mar 12, 2024
2 parents eddc198 + 3790b00 commit b33dd7a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 61 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,5 @@ dmypy.json
notebooks/.ipynb_checkpoints/

flexmeasures.log

.gitconfig.*
24 changes: 15 additions & 9 deletions flexmeasures_openweathermap/cli/tests/test_get_forecasts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from flexmeasures.data.models.time_series import TimedBelief

from ..commands import collect_weather_data
Expand Down Expand Up @@ -43,21 +45,25 @@ def test_get_weather_forecasts_to_db(


def test_get_weather_forecasts_no_close_sensors(
app, db, monkeypatch, run_as_cli, add_weather_sensors_fresh_db
app, db, monkeypatch, run_as_cli, add_weather_sensors_fresh_db, caplog
):
"""
Looking for a location too far away from existing weather stations means we fail.
Looking for a location too far away from existing weather station.
Check we get a warning.
"""
weather_station = add_weather_sensors_fresh_db["wind"].generic_asset

monkeypatch.setitem(app.config, "OPENWEATHERMAP_API_KEY", "dummy")
monkeypatch.setattr(owm, "call_openweatherapi", mock_owm_response)

runner = app.test_cli_runner()
result = runner.invoke(
collect_weather_data,
["--location", f"{weather_station.latitude-5},{weather_station.longitude}"],
)
print(result.output)
assert "Reported task get-openweathermap-forecasts status as False" in result.output
assert "No sufficiently close weather sensor found" in result.output
with caplog.at_level(logging.WARNING):
result = runner.invoke(
collect_weather_data,
["--location", f"{weather_station.latitude-5},{weather_station.longitude}"],
)
print(result.output)
assert (
"Reported task get-openweathermap-forecasts status as True" in result.output
)
assert "no sufficiently close weather sensor found" in caplog.text
8 changes: 2 additions & 6 deletions requirements/app.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --output-file=requirements/app.txt requirements/app.in
Expand Down Expand Up @@ -165,13 +165,10 @@ idna==3.4
# tldextract
importlib-metadata==6.1.0
# via
# flask
# flexmeasures
# timely-beliefs
importlib-resources==5.12.0
# via
# flexmeasures
# matplotlib
# via flexmeasures
inflect==6.0.2
# via flexmeasures
inflection==0.5.1
Expand Down Expand Up @@ -494,7 +491,6 @@ zipp==3.15.0
# via
# flexmeasures
# importlib-metadata
# importlib-resources

# The following packages are considered to be unsafe in a requirements file:
# setuptools
22 changes: 7 additions & 15 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --output-file=requirements/dev.txt requirements/dev.in
#
black==22.8.0
# via -r requirements/dev.in
cfgv==3.3.1
# via pre-commit
click==8.0.3
click==8.1.3
# via
# -c requirements/app.txt
# -c requirements/test.txt
# black
distlib==0.3.6
# via virtualenv
filelock==3.4.2
filelock==3.10.7
# via
# -c requirements/app.txt
# virtualenv
Expand All @@ -35,7 +35,7 @@ mypy-extensions==0.4.3
# mypy
nodeenv==1.7.0
# via pre-commit
packaging==21.3
packaging==23.0
# via
# -c requirements/app.txt
# -c requirements/test.txt
Expand All @@ -52,17 +52,10 @@ pycodestyle==2.9.1
# via flake8
pyflakes==2.5.0
# via flake8
pyparsing==3.0.7
# via
# -c requirements/app.txt
# -c requirements/test.txt
# packaging
pytest-runner==6.0.0
# via -r requirements/dev.in
pyyaml==6.0
# via
# -c requirements/app.txt
# pre-commit
# via pre-commit
setuptools-scm==7.0.5
# via -r requirements/dev.in
toml==0.10.2
Expand All @@ -73,10 +66,9 @@ tomli==2.0.1
# black
# mypy
# setuptools-scm
typing-extensions==4.1.1
typing-extensions==4.5.0
# via
# -c requirements/app.txt
# black
# mypy
# setuptools-scm
virtualenv==20.16.5
Expand Down
47 changes: 16 additions & 31 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,59 +1,54 @@
#
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --output-file=requirements/test.txt requirements/test.in
#
attrs==21.4.0
async-timeout==4.0.2
# via
# -c requirements/app.txt
# redis
attrs==22.2.0
# via
# -c requirements/app.txt
# pytest
click==8.0.3
click==8.1.3
# via
# -c requirements/app.txt
# flask
coverage[toml]==6.4.4
# via pytest-cov
deprecated==1.2.13
# via
# -c requirements/app.txt
# redis
fakeredis==1.9.1
fakeredis==2.16.0
# via -r requirements/test.in
flask==2.0.2
flask==2.1.2
# via
# -c requirements/app.txt
# pytest-flask
iniconfig==1.1.1
# via pytest
itsdangerous==2.0.1
itsdangerous==2.1.2
# via
# -c requirements/app.txt
# flask
jinja2==3.0.3
jinja2==3.1.2
# via
# -c requirements/app.txt
# flask
lupa==1.13
# via -r requirements/test.in
markupsafe==2.0.1
markupsafe==2.1.2
# via
# -c requirements/app.txt
# jinja2
packaging==21.3
packaging==23.0
# via
# -c requirements/app.txt
# pytest
# pytest-sugar
# redis
pluggy==1.0.0
# via pytest
py==1.11.0
# via pytest
pyparsing==3.0.7
# via
# -c requirements/app.txt
# packaging
pytest==7.1.3
# via
# -r requirements/test.in
Expand All @@ -66,18 +61,12 @@ pytest-flask==1.2.0
# via -r requirements/test.in
pytest-sugar==0.9.5
# via -r requirements/test.in
redis==4.1.3
# via
# -c requirements/app.txt
# fakeredis
six==1.16.0
redis==4.5.4
# via
# -c requirements/app.txt
# fakeredis
sortedcontainers==2.4.0
# via
# -c requirements/app.txt
# fakeredis
# via fakeredis
termcolor==2.0.1
# via pytest-sugar
tomli==2.0.1
Expand All @@ -89,7 +78,3 @@ werkzeug==2.0.3
# -c requirements/app.txt
# flask
# pytest-flask
wrapt==1.13.3
# via
# -c requirements/app.txt
# deprecated

0 comments on commit b33dd7a

Please sign in to comment.