Skip to content

Commit

Permalink
Change library name
Browse files Browse the repository at this point in the history
  • Loading branch information
saaste committed Feb 10, 2020
1 parent 61f7ac6 commit e132012
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 25 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
![Test](https://github.com/saaste/fmi-weather/workflows/tests/badge.svg?branch=master)
![Last commit](https://img.shields.io/github/last-commit/saaste/fmi-weather)

# Finnish Meteorological Institute Weather
Library for fetching weather information from
[Finnish Meteorological Institute (FMI)](https://en.ilmatieteenlaitos.fi/open-data).
Expand All @@ -17,28 +18,28 @@ Working example can be found in [example.py](example.py).

Weather station depends on FMI service.
```python
import fmi_weather
import fmi_weather_client

weather = fmi_weather.weather_by_place_name("Mäkkylä, Espoo")
weather = fmi_weather_client.weather_by_place_name("Mäkkylä, Espoo")
```

If place name is not known or weather data is not available, the following exception is thrown:
```
fmi_weather.errors.NoWeatherDataError
fmi_weather_client.errors.NoWeatherDataError
```

### Get the weather by coordinates

Weather stations is the closest one
```python
import fmi_weather
import fmi_weather_client

weather = fmi_weather.weather_by_coordinates(63.361604, 27.392607)
weather = fmi_weather_client.weather_by_coordinates(63.361604, 27.392607)
```

If there are no stations within 50 km, the following exception is thrown:
```
fmi_weather.errors.NoWeatherDataError
fmi_weather_client.errors.NoWeatherDataError
```


Expand Down
6 changes: 3 additions & 3 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fmi_weather
import fmi_weather_client


def print_weather(weather):
Expand All @@ -17,8 +17,8 @@ def print_weather(weather):
print('Cloud coverage: %s' % weather.cloud_coverage)


weather = fmi_weather.weather_by_coordinates(67.2463, 23.6659)
weather2 = fmi_weather.weather_by_place_name("Iisalmi")
weather = fmi_weather_client.weather_by_coordinates(67.2463, 23.6659)
weather2 = fmi_weather_client.weather_by_place_name("Iisalmi")

print_weather(weather)
print('')
Expand Down
2 changes: 1 addition & 1 deletion fmi_weather/__init__.py → fmi_weather_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import requests

from fmi_weather import parser
from fmi_weather_client import parser

_BASE_URL = 'http://opendata.fmi.fi/wfs'

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion fmi_weather/models.py → fmi_weather_client/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime
from typing import Optional
from fmi_weather import utils
from fmi_weather_client import utils


class WeatherMeasurement:
Expand Down
2 changes: 1 addition & 1 deletion fmi_weather/parser.py → fmi_weather_client/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import xmltodict

from fmi_weather import errors, models, utils
from fmi_weather_client import errors, models, utils


def parse_weather_data(response,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import unittest
from unittest import mock

import fmi_weather
import fmi_weather.test.test_data as test_data
from fmi_weather.errors import NoWeatherDataError, ServiceError
import fmi_weather_client
import fmi_weather_client.test.test_data as test_data
from fmi_weather_client.errors import NoWeatherDataError, ServiceError


class FMIWeatherTest(unittest.TestCase):

@mock.patch('requests.get', side_effect=test_data.mock_place_response)
def test_get_weather_by_place(self, mock_get):
place_weather = fmi_weather.weather_by_place_name('Espoo, Tapiola')
place_weather = fmi_weather_client.weather_by_place_name('Espoo, Tapiola')
self.assertEqual(place_weather.station_name, 'Espoo Tapiola')

@mock.patch('requests.get', side_effect=test_data.mock_bbox_response)
def test_get_weather_by_station(self, mock_get):
place_weather = fmi_weather.weather_by_coordinates(27.31317, 63.14343)
place_weather = fmi_weather_client.weather_by_coordinates(27.31317, 63.14343)
self.assertEqual(place_weather.station_name, 'Kuopio Maaninka')

@mock.patch('requests.get', side_effect=test_data.mock_empty_response)
def test_empty_response(self, mock_get):
with self.assertRaises(NoWeatherDataError):
fmi_weather.weather_by_coordinates(27.31317, 63.14343)
fmi_weather_client.weather_by_coordinates(27.31317, 63.14343)

@mock.patch('requests.get', side_effect=test_data.mock_no_location_exception_response)
def test_no_location_exception_response(self, mock_get):
with self.assertRaises(NoWeatherDataError):
fmi_weather.weather_by_coordinates(27.31317, 63.14343)
fmi_weather_client.weather_by_coordinates(27.31317, 63.14343)

@mock.patch('requests.get', side_effect=test_data.mock_other_exception_response)
def test_other_exception_response(self, mock_get):
with self.assertRaises(ServiceError):
fmi_weather.weather_by_coordinates(27.31317, 63.14343)
fmi_weather_client.weather_by_coordinates(27.31317, 63.14343)


if __name__ == '__main__':
Expand Down
File renamed without changes.
13 changes: 8 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@
long_description = fh.read()

setuptools.setup(
name="fmi_weather",
name="fmi-weather-client",
version="0.0.1",
author="Mika Hiltunen",
author_email="saaste@gmail.com",
description="Library for fetching weather information from Finnish Meteorological Institute (FMI)",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/saaste/fmi-weather",
url="https://github.com/saaste/fmi-weather-client",
packages=setuptools.find_packages(),
install_requires=[
'requests'
'requests>=2.22.0',
'xmltodict>=0.12.0'
],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GPL License",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: OS Independent",
],
python_requires='>=3.6.9',
Expand Down

0 comments on commit e132012

Please sign in to comment.