1010from tests .unit .airpollutionapi30 .test_coindex import COINDEX_JSON
1111from tests .unit .airpollutionapi30 .test_no2index import NO2INDEX_JSON
1212from tests .unit .airpollutionapi30 .test_so2index import SO2INDEX_JSON
13- from tests .unit .airpollutionapi30 .test_airstatus import AIRSTATUS_JSON
13+ from tests .unit .airpollutionapi30 .test_airstatus import AIRSTATUS_JSON , AIRSTATUS_MULTIPLE_JSON
1414
1515
1616class TestAirPollutionManager (unittest .TestCase ):
@@ -29,6 +29,9 @@ def mock_get_no2_returning_no2index_around_coords(self, params_dict):
2929 def mock_get_air_pollution (self , params_dict ):
3030 return json .loads (AIRSTATUS_JSON )
3131
32+ def mock_get_forecast_air_pollution (self , params_dict ):
33+ return json .loads (AIRSTATUS_MULTIPLE_JSON )
34+
3235 def mock_get_so2_returning_so2index_around_coords (self , params_dict ):
3336 return json .loads (SO2INDEX_JSON )
3437
@@ -199,5 +202,32 @@ def test_air_quality_at_coords_fails_with_wrong_parameters(self):
199202 self .assertRaises (ValueError , airpollution_manager .AirPollutionManager .air_quality_at_coords , \
200203 self .__test_instance , 200 , 2.5 )
201204
205+ def test_air_quality_forecast_at_coords (self ):
206+ ref_to_original = airpollution_client .AirPollutionHttpClient .get_forecast_air_pollution
207+ airpollution_client .AirPollutionHttpClient .get_forecast_air_pollution = \
208+ self .mock_get_forecast_air_pollution
209+ result = self .__test_instance .air_quality_forecast_at_coords (45 , 9 )
210+ airpollution_client .AirPollutionHttpClient .get_forecast_air_pollution = ref_to_original
211+ self .assertTrue (isinstance (result , list ))
212+ for item in result :
213+ self .assertIsInstance (item , airstatus .AirStatus )
214+ self .assertIsNotNone (item .reference_time )
215+ self .assertIsNotNone (item .reception_time ())
216+ loc = item .location
217+ self .assertIsNotNone (loc )
218+ self .assertIsNotNone (loc .lat )
219+ self .assertIsNotNone (loc .lon )
220+ self .assertIsNotNone (item .air_quality_data )
221+
222+ def test_air_quality_forecast_at_coords_fails_with_wrong_parameters (self ):
223+ self .assertRaises (ValueError , airpollution_manager .AirPollutionManager .air_quality_forecast_at_coords , \
224+ self .__test_instance , 43.7 , - 200.0 )
225+ self .assertRaises (ValueError , airpollution_manager .AirPollutionManager .air_quality_forecast_at_coords , \
226+ self .__test_instance , 43.7 , 200.0 )
227+ self .assertRaises (ValueError , airpollution_manager .AirPollutionManager .air_quality_forecast_at_coords , \
228+ self .__test_instance , - 200 , 2.5 )
229+ self .assertRaises (ValueError , airpollution_manager .AirPollutionManager .air_quality_forecast_at_coords , \
230+ self .__test_instance , 200 , 2.5 )
231+
202232 def test_repr (self ):
203233 print (self .__test_instance )
0 commit comments