Skip to content

Commit

Permalink
Restrict weather report to germany
Browse files Browse the repository at this point in the history
  • Loading branch information
FL550 committed Apr 27, 2021
1 parent b8efccf commit 25f34cc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="simple_dwd_weatherforecast",
version="1.0.16",
version="1.0.17",
author="Max Fermor",
description="A simple tool to retrieve a weather forecast from DWD OpenData",
long_description=long_description,
Expand Down
2 changes: 1 addition & 1 deletion simple_dwd_weatherforecast/dwdforecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_region(station_id: str):
if len(line) > 1:
if line[:6].strip() == station_id:
region = line[53:]
if region != "":
if region != "" and region in Weather.region_codes:
return region
return None
return None
Expand Down
5 changes: 4 additions & 1 deletion tests/test_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ def test_get_region_empty(self):
self.assertIsNone(dwdforecast.get_region("10015"))

def test_get_region_not_valid(self):
self.assertIsNone(dwdforecast.get_region("10"))
self.assertIsNone(dwdforecast.get_region("10"))

def test_region_not_in_germany(self):
self.assertIsNone(dwdforecast.get_region("06240"))

0 comments on commit 25f34cc

Please sign in to comment.