from weather_au import place # Parse http://www.bom.gov.au/places/vic/parkville place_data = place.Place('vic', 'endeavour-hills') print(place_data.acknowedgment, '\n') station_id = place_data.station_id() air_temperature = place_data.air_temperature() print(f'Station ID: {station_id}\nAir Temperature: {air_temperature}°C') forecast = place_data.forecast() print('\nForecast', forecast) # mising data in forecast is omitted if 'precis' in forecast: print('Precis', forecast['precis']) else: print('No precis available')
import os, sys sys.path.append(os.path.abspath('.')) import pytest import urllib from weather_au import place def test_404(): with pytest.raises(urllib.error.HTTPError, match='HTTP Error 404: Not Found'): place_data = place.Place('vic', 'zzz') place_data = place.Place('vic', 'parkville') def test_obs(): assert place_data is not None def test_acknowedgment_url(): assert len(place_data.url) > 0 assert len(place_data.acknowedgment) > 0 def test_station_id(): station_id = place_data.station_id() assert station_id is not None assert len(station_id) == 5 def test_forecast(): forecast = place_data.forecast() assert 'issued' in forecast assert 'date' in forecast
def test_404(): with pytest.raises(urllib.error.HTTPError, match='HTTP Error 404: Not Found'): place_data = place.Place('vic', 'zzz')
import os, sys sys.path.append(os.path.abspath('.')) import pytest import urllib from weather_au import place def test_404(): with pytest.raises(urllib.error.HTTPError, match='HTTP Error 404: Not Found'): place_data = place.Place('vic', 'zzz') place_data = place.Place('vic', 'parkville') def test_obs(): assert place_data is not None def test_acknowedgment_url(): assert len(place_data.url) > 0 assert len(place_data.acknowedgment) > 0 def test_station_id(): station_id = place_data.station_id() assert station_id is not None assert len(station_id) == 5 def test_forecast_parkville(): forecast = place_data.forecast() assert 'issued' in forecast assert 'date' in forecast