77from pyowm .commons .exceptions import APIResponseError , ParseAPIResponseError
88from pyowm .utils .formatting import UTC
99from 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
1414class 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