Skip to content

Commit 14f3841

Browse files
committed
bump to version 3
2 parents 98be51d + cdd59eb commit 14f3841

File tree

15 files changed

+77
-83
lines changed

15 files changed

+77
-83
lines changed

pyowm/weatherapi25/forecast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,4 @@ def __iter__(self):
144144
def __repr__(self):
145145
return "<%s.%s - reception_time=%s, interval=%s>" % (__name__, \
146146
self.__class__.__name__, self.reception_time('iso'),
147-
self.interval)
147+
self.interval)

pyowm/weatherapi25/location.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ def to_dict(self):
112112
def __repr__(self):
113113
return "<%s.%s - id=%s, name=%s, lon=%s, lat=%s>" % (__name__, \
114114
self.__class__.__name__, self.id, self.name, str(self.lon), \
115-
str(self.lat))
115+
str(self.lat))

pyowm/weatherapi25/observation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ def from_dict_of_lists(self, the_dict):
142142
return [Observation.from_dict(item) for item in the_dict['list']]
143143

144144
# no way out..
145-
raise exceptions.ParseAPIResponseError(''.join([__name__, ': impossible to read JSON data']))
145+
raise exceptions.ParseAPIResponseError(''.join([__name__, ': impossible to read JSON data']))

pyowm/weatherapi25/stationhistory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ def to_dict(self):
132132
"measurements": self.measurements}
133133

134134
def __repr__(self):
135-
return "<%s.%s - station_id=%s, interval=%s>" % (__name__, self.__class__.__name__, self.station_id, self.interval)
135+
return "<%s.%s - station_id=%s, interval=%s>" % (__name__, self.__class__.__name__, self.station_id, self.interval)

pyowm/weatherapi25/weather.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,4 +505,4 @@ def to_dict(self):
505505
'humidex': self.humidex,
506506
'heat_index': self.heat_index,
507507
'utc_offset': self.utc_offset,
508-
'uvi': self.uvi}
508+
'uvi': self.uvi}

tests/integration/commons/test_http_client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ def test_get_geotiff(self):
7373
self.assertIsNotNone(data)
7474
self.assertIsInstance(data, bytes)
7575

76+
def test_get_png(self):
77+
# http://httpbin.org/image/png
78+
status, data = self.instance.get_png('http://httpbin.org/image/png')
79+
self.assertIsNotNone(data)
80+
self.assertIsInstance(data, bytes)
81+
82+
def test_get_geotiff(self):
83+
# https://download.osgeo.org/geotiff/samples/made_up/bogota.tif
84+
status, data = self.instance.get_geotiff('https://download.osgeo.org/geotiff/samples/made_up/bogota.tif')
85+
self.assertIsNotNone(data)
86+
self.assertIsInstance(data, bytes)
87+
7688

7789
if __name__ == "__main__":
7890
unittest.main()

tests/integration/weatherapi25/test_ssl.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/unit/utils/test_geo.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ def test_polygon_points(self):
175175
self.assertTrue(result)
176176
self.assertTrue(all([isinstance(p, geo.Point) for p in result]))
177177

178+
def test_polygon_points(self):
179+
p = geo.Polygon([[[2.3, 57.32], [23.19, -20.2], [-120.4, 19.15], [2.3, 57.32]]])
180+
result = p.points
181+
self.assertTrue(result)
182+
self.assertTrue(all([isinstance(p, geo.Point) for p in result]))
183+
178184
def test_polygon_from_points(self):
179185
expected = geo.Polygon([[[2.3, 57.32], [23.19, -20.2], [2.3, 57.32]]])
180186
list_of_lists = [

tests/unit/weatherapi25/json_test_responses.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
'"weather":[{"id":803,"main":"Clouds","description":"brokenclouds","icon":"04d"}]}]}'
2020

2121

22+
WEATHER_AT_PLACES_IN_BBOX_JSON = '{"cod":"200","calctime":0.3107,"cnt":2,' \
23+
'"list":[{"id":2208791,"name":"Yafran","coord":{"lon":12.52859,"lat":32.06329},"main":{"temp":9.68,"temp_min":9.681,' \
24+
'"temp_max":9.681,"pressure":961.02,"sea_level":1036.82,"grnd_level":961.02,"humidity":85},"dt":1485784982,' \
25+
'"wind":{"speed":3.96,"deg":356.5},"rain":{"3h":0.255},"clouds":{"all":88},"weather":[{"id":500,"main":"Rain",' \
26+
'"description":"lightrain","icon":"10d"}]},{"id":2208425,"name":"Zuwarah","coord":{"lon":12.08199,"lat":32.931198},' \
27+
'"main":{"temp":15.36,"temp_min":15.356,"temp_max":15.356,"pressure":1036.81,"sea_level":1037.79,' \
28+
'"grnd_level":1036.81,"humidity":89},"dt":1485784982,"wind":{"speed":5.46,"deg":30.0002},"clouds":{"all":56},' \
29+
'"weather":[{"id":803,"main":"Clouds","description":"brokenclouds","icon":"04d"}]}]}'
30+
31+
2232
SEARCH_RESULTS_JSON = '{"cod": "200", "count": 2, "list": [{"clouds": {"all": ' \
2333
'20}, "coord": {"lat": 51.50853, "lon": -0.12573999999999999}, "dt": 1378237178,' \
2434
' "id": 2643743, "main": {"humidity": 56, "pressure": 1025, "temp": ' \

tests/unit/weatherapi25/test_forecast.py

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,41 @@
77
from pyowm.commons.exceptions import APIResponseError, ParseAPIResponseError
88
from pyowm.utils.formatting import UTC
99
from tests.unit.weatherapi25.json_test_responses import (
10-
THREE_HOURS_FORECAST_JSON, FORECAST_NOT_FOUND_JSON,
11-
INTERNAL_SERVER_ERROR_JSON, FORECAST_MALFORMED_JSON)
10+
THREE_HOURS_FORECAST_JSON, FORECAST_NOT_FOUND_JSON,
11+
INTERNAL_SERVER_ERROR_JSON, FORECAST_MALFORMED_JSON)
1212

1313

1414
class TestForecast(unittest.TestCase):
15-
1615
__test_reception_time = 1234567
1716
__test_iso_reception_time = "1970-01-15 06:56:07+00"
1817
__test_date_reception_time = datetime.strptime(__test_iso_reception_time,
19-
'%Y-%m-%d %H:%M:%S+00').replace(tzinfo=UTC())
18+
'%Y-%m-%d %H:%M:%S+00').replace(tzinfo=UTC())
2019
__test_location = Location('test', 12.3, 43.7, 987, 'IT')
2120
__test_weathers = [Weather(1378459200, 1378496400, 1378449600, 67,
22-
{"all": 20}, {"all": 0}, {"deg": 252.002, "speed": 1.100}, 57,
23-
{"press": 1030.119, "sea_level": 1038.589},
24-
{"temp": 294.199, "temp_kf": -1.899, "temp_max": 296.098,
25-
"temp_min": 294.199
26-
},
27-
"Clouds", "Overcast clouds", 804, "04d", 1000, 300.0, 298.0, 296.0),
28-
Weather(1378459690, 1378496480, 1378449510, 23, {"all": 10},
29-
{"all": 0}, {"deg": 103.4, "speed": 4.2}, 12,
30-
{"press": 1070.119, "sea_level": 1078.589},
31-
{"temp": 297.199, "temp_kf": -1.899, "temp_max": 299.0,
32-
"temp_min": 295.6
33-
},
34-
"Clear", "Sky is clear", 804, "02d", 1000, 300.0, 298.0, 296.0)
35-
]
21+
{"all": 20}, {"all": 0}, {"deg": 252.002, "speed": 1.100}, 57,
22+
{"press": 1030.119, "sea_level": 1038.589},
23+
{"temp": 294.199, "temp_kf": -1.899, "temp_max": 296.098,
24+
"temp_min": 294.199
25+
},
26+
"Clouds", "Overcast clouds", 804, "04d", 1000, 300.0, 298.0, 296.0),
27+
Weather(1378459690, 1378496480, 1378449510, 23, {"all": 10},
28+
{"all": 0}, {"deg": 103.4, "speed": 4.2}, 12,
29+
{"press": 1070.119, "sea_level": 1078.589},
30+
{"temp": 297.199, "temp_kf": -1.899, "temp_max": 299.0,
31+
"temp_min": 295.6
32+
},
33+
"Clear", "Sky is clear", 804, "02d", 1000, 300.0, 298.0, 296.0)
34+
]
3635
__test_n_weathers = len(__test_weathers)
3736
__test_instance = Forecast("daily", __test_reception_time, __test_location,
3837
__test_weathers)
3938
__bad_json = '{"a": "test", "b": 1.234, "c": [ "hello", "world"] }'
4039
__bad_json_2 = '{ "city": {"id": 2643743,' \
41-
'"name": "London","coord": {"lon": -0.12574,"lat": 51.50853},"country": ' \
42-
'"GB","population": 1000000} }'
40+
'"name": "London","coord": {"lon": -0.12574,"lat": 51.50853},"country": ' \
41+
'"GB","population": 1000000} }'
4342
__no_items_found_json = '{"count": "0", "city": {"id": 2643743,' \
44-
'"name": "London","coord": {"lon": -0.12574,"lat": 51.50853},"country": ' \
45-
'"GB","population": 1000000} }'
43+
'"name": "London","coord": {"lon": -0.12574,"lat": 51.50853},"country": ' \
44+
'"GB","population": 1000000} }'
4645

4746
FORECAST_JSON_DUMP = '{"reception_time": 1234567, "interval": "daily", ' \
4847
'"location": {"country": "IT", "name": "test", ' \
@@ -72,21 +71,21 @@ class TestForecast(unittest.TestCase):
7271

7372
def test_actualize(self):
7473
weathers = [Weather(1378459200, 1378496400, 1378449600, 67,
75-
{"all": 20}, {"all": 0}, {"deg": 252.002, "speed": 1.100}, 57,
76-
{"press": 1030.119, "sea_level": 1038.589},
77-
{"temp": 294.199, "temp_kf": -1.899, "temp_max": 296.098,
78-
"temp_min": 294.199
79-
},
80-
"Clouds", "Overcast clouds", 804, "04d", 1000, 300.0, 298.0, 296.0),
81-
# will this time ever be reached?
82-
Weather(9999999999, 1378496480, 1378449510, 23, {"all": 10},
83-
{"all": 0}, {"deg": 103.4, "speed": 4.2}, 12,
84-
{"press": 1070.119, "sea_level": 1078.589},
85-
{"temp": 297.199, "temp_kf": -1.899, "temp_max": 299.0,
86-
"temp_min": 295.6
87-
},
88-
"Clear", "Sky is clear", 804, "02d", 1000, 300.0, 298.0, 296.0)
89-
]
74+
{"all": 20}, {"all": 0}, {"deg": 252.002, "speed": 1.100}, 57,
75+
{"press": 1030.119, "sea_level": 1038.589},
76+
{"temp": 294.199, "temp_kf": -1.899, "temp_max": 296.098,
77+
"temp_min": 294.199
78+
},
79+
"Clouds", "Overcast clouds", 804, "04d", 1000, 300.0, 298.0, 296.0),
80+
# will this time ever be reached?
81+
Weather(9999999999, 1378496480, 1378449510, 23, {"all": 10},
82+
{"all": 0}, {"deg": 103.4, "speed": 4.2}, 12,
83+
{"press": 1070.119, "sea_level": 1078.589},
84+
{"temp": 297.199, "temp_kf": -1.899, "temp_max": 299.0,
85+
"temp_min": 295.6
86+
},
87+
"Clear", "Sky is clear", 804, "02d", 1000, 300.0, 298.0, 296.0)
88+
]
9089
f = Forecast("daily", self.__test_reception_time, self.__test_location,
9190
weathers)
9291
self.assertEqual(2, len(f))
@@ -107,7 +106,7 @@ def test_getters_return_expected_3h_data(self):
107106
Test either for "3h" forecast and "daily" ones
108107
"""
109108
instance = Forecast("3h", self.__test_reception_time,
110-
self.__test_location, self.__test_weathers)
109+
self.__test_location, self.__test_weathers)
111110
self.assertEqual(instance.interval, "3h")
112111
self.assertEqual(instance.reception_time(),
113112
self.__test_reception_time)
@@ -116,7 +115,7 @@ def test_getters_return_expected_3h_data(self):
116115

117116
def test_getters_return_expected_daily_data(self):
118117
instance = Forecast("daily", self.__test_reception_time,
119-
self.__test_location, self.__test_weathers)
118+
self.__test_location, self.__test_weathers)
120119
self.assertEqual(instance.interval, "daily")
121120
self.assertEqual(instance.reception_time(),
122121
self.__test_reception_time)
@@ -139,7 +138,7 @@ def test__iter__(self):
139138
self.assertTrue(isinstance(weather, Weather))
140139
counter += 1
141140
self.assertEqual(len(instance.weathers), counter)
142-
141+
143142
def test__len__(self):
144143
self.assertEqual(len(self.__test_instance), len(self.__test_weathers))
145144

@@ -184,4 +183,4 @@ def test_to_dict(self):
184183
self.assertEqual(expected, result)
185184

186185
def test__repr(self):
187-
print(self.__test_instance)
186+
print(self.__test_instance)

0 commit comments

Comments
 (0)