def test_hurricane(m): with open('hurricane.json') as f: m.get('http://api.wunderground.com/api/{}/currenthurricane/view.json'.format(my_secret_key), text=f.read()) hurricane = GetHurricane() res = hurricane.run() assert res == 'Hurricane 1 is named Hurricane Olaf and is located at lattitude 9.9 and longitude -137.7'
def weather_app(zipcode): while True: selection = input( """Welcome to your weather app for zip-code {}. Enter [1] for current conditions. Enter [2] for sunrise and sunset times. Enter [3] for a ten-day forecast. Enter [4] for any active alerts. Enter [5] to see any active hurricanes worldwide. Enter [q] to quit\n\n> """.format( zipcode ) ) if re.match(r"[1-5q]{1}$", selection): if selection == "1": print(GetConditions(zipcode).run()) print("-------------------------------------------------") elif selection == "2": print(GetSunrise(zipcode).run()) print("-------------------------------------------------") elif selection == "3": print(GetTenDay(zipcode).run()) print("-------------------------------------------------") elif selection == "4": print(GetAlerts(zipcode).run()) print("-------------------------------------------------") elif selection == "5": print(GetHurricane.run()) print("-------------------------------------------------") else: break else: print("That is not a valid choice\n") return weather_app(zipcode)