예제 #1
0
async def test_nws_set_station_none(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    nws = SimpleNWS(*LATLON, USERID, client)
    await nws.set_station()
    assert nws.station == "KCMH"
    assert isinstance(nws.stations, list)
예제 #2
0
async def test_nws_alerts_fire_weather_zone(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    nws = SimpleNWS(*LATLON, USERID, client)
    await nws.update_alerts_fire_weather_zone()
    alerts = nws.alerts_fire_weather_zone
    assert alerts
예제 #3
0
async def test_nws_set_station(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    nws = SimpleNWS(*LATLON, USERID, client)
    await nws.set_station(STATION)
    assert nws.station == STATION
    assert nws.stations == [STATION]
예제 #4
0
async def test_nws_forecast_hourly(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    nws = SimpleNWS(*LATLON, USERID, client)
    await nws.update_forecast_hourly()
    forecast = nws.forecast_hourly

    assert forecast[0]["temperature"] == 78
예제 #5
0
async def test_nws_points_stations(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    nws = Nws(client, USERID, LATLON)
    assert nws
    stations = await nws.get_points_stations()
    assert stations
    assert isinstance(stations, list)
예제 #6
0
async def test_nws_forecast_empty(aiohttp_client, loop, mock_urls):
    app = setup_app(gridpoints_forecast="gridpoints_forecast_empty.json")
    client = await aiohttp_client(app)
    nws = SimpleNWS(*LATLON, USERID, client)
    await nws.update_forecast()
    forecast = nws.forecast

    assert forecast == []
예제 #7
0
async def test_nws_alerts_forecast_zone(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    nws = Nws(client, USERID, LATLON)
    assert nws
    alerts = await nws.get_alerts_forecast_zone()
    assert alerts
    assert isinstance(alerts, list)
예제 #8
0
async def test_nws_gridpoints_forecast_hourly(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    nws = Nws(client, USERID, LATLON)
    assert nws
    forecast = await nws.get_gridpoints_forecast_hourly()
    assert nws.wfo
    assert forecast
    assert isinstance(forecast, list)
예제 #9
0
async def test_stations_observations_start_datetime(aiohttp_client, loop,
                                                    mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    with pytest.raises(ValueError):
        await raw_data.raw_stations_observations(STATION,
                                                 client,
                                                 USERID,
                                                 start="1PM")
예제 #10
0
async def test_stations_observations(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    await raw_data.raw_stations_observations(STATION, client, USERID)
    await raw_data.raw_stations_observations(STATION, client, USERID, limit=2)
    await raw_data.raw_stations_observations(STATION,
                                             client,
                                             USERID,
                                             start=datetime.now(timezone.utc))
예제 #11
0
async def test_nws_observation_metar_noparse(aiohttp_client, loop, mock_urls):
    app = setup_app(
        stations_observations="stations_observations_metar_noparse.json")
    client = await aiohttp_client(app)
    nws = SimpleNWS(*LATLON, USERID, client)
    await nws.set_station(STATION)
    await nws.update_observation()
    observation = nws.observation
    assert observation["temperature"] is None
예제 #12
0
async def test_nws_alerts_all_zones(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    nws = SimpleNWS(*LATLON, USERID, client)
    new_alerts = await nws.update_alerts_all_zones()
    assert len(nws.all_zones) == 2
    assert new_alerts
    alerts = nws.alerts_all_zones
    assert alerts
    assert new_alerts == alerts
    assert len(alerts) == 1
예제 #13
0
async def test_nws_stations_observations(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    nws = Nws(client, USERID, LATLON)
    assert nws
    with pytest.raises(NwsError):
        stations = await nws.get_stations_observations()
    nws.station = STATION
    observations = await nws.get_stations_observations()
    assert observations
    assert isinstance(observations, list)
예제 #14
0
async def test_nws_observation_units(aiohttp_client, loop, mock_urls):
    app = setup_app(
        stations_observations="stations_observations_alternate_units.json")
    client = await aiohttp_client(app)
    nws = SimpleNWS(*LATLON, USERID, client)
    await nws.set_station(STATION)
    await nws.update_observation()
    observation = nws.observation
    assert observation
    assert round(observation["temperature"], 1) == -12.2
    assert observation["windSpeed"] == 10  # converted to km_gr
    assert observation["windGust"] == 10
예제 #15
0
async def test_nws_points(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    nws = Nws(client, USERID, LATLON)
    assert nws
    points = await nws.get_points()
    assert points
    assert nws.wfo
    assert nws.x
    assert nws.y
    assert nws.forecast_zone
    assert nws.county_zone
    assert nws.fire_weather_zone
예제 #16
0
async def test_nws_alerts_all_zones_second_alert(aiohttp_client, loop,
                                                 mock_urls):
    app = setup_app(alerts_active_zone=[
        "alerts_active_zone.json", "alerts_active_zone_second.json"
    ])
    client = await aiohttp_client(app)
    nws = SimpleNWS(*LATLON, USERID, client)
    new_alerts = await nws.update_alerts_all_zones()
    assert len(nws.all_zones) == 2
    assert new_alerts
    alerts = nws.alerts_all_zones
    assert alerts
    assert new_alerts == alerts
    assert len(alerts) == 2
예제 #17
0
async def test_nws_forecast_strings(aiohttp_client, loop, mock_urls):
    app = setup_app(gridpoints_forecast="gridpoints_forecast_strings.json")
    client = await aiohttp_client(app)
    nws = SimpleNWS(*LATLON, USERID, client)
    await nws.update_forecast()
    forecast = nws.forecast

    assert forecast[0]["iconWeather"][0][
        0] == "Thunderstorm (high cloud cover)"
    assert forecast[0]["iconWeather"][0][1] == 40
    assert forecast[0]["iconWeather"][1][0] == "Overcast"
    assert forecast[0]["iconWeather"][1][1] is None
    assert forecast[0]["windSpeedAvg"] == 10
    assert forecast[0]["windBearing"] == 180
예제 #18
0
async def test_nws_observation_metar(aiohttp_client, loop, mock_urls):
    app = setup_app(stations_observations="stations_observations_metar.json")
    client = await aiohttp_client(app)
    nws = SimpleNWS(*LATLON, USERID, client)
    await nws.set_station(STATION)
    await nws.update_observation()
    observation = nws.observation

    assert observation["temperature"] == 25.6
    assert observation["dewpoint"] is None
    assert observation["relativeHumidity"] is None
    assert observation["windDirection"] == 350.0
    assert observation["visibility"] == 16093.44
    assert round(observation["seaLevelPressure"]) == 101761
    assert round(observation["windSpeed"], 2) == 9.26
    assert observation["windGust"] is None
예제 #19
0
async def test_nws_observation_empty(aiohttp_client, loop, mock_urls):
    app = setup_app(stations_observations="stations_observations_empty.json")
    client = await aiohttp_client(app)
    nws = SimpleNWS(*LATLON, USERID, client)
    await nws.set_station(STATION)
    await nws.update_observation()
    observation = nws.observation

    assert observation["temperature"] is None
    assert observation["dewpoint"] is None
    assert observation["relativeHumidity"] is None
    assert observation["windDirection"] is None
    assert observation["visibility"] is None
    assert observation["seaLevelPressure"] is None
    assert observation["windSpeed"] is None
    assert observation["windGust"] is None
    assert observation["iconTime"] is None
    assert observation["iconWeather"] is None
예제 #20
0
async def test_nws_observation(aiohttp_client, loop, mock_urls,
                               observation_json):
    app = setup_app(stations_observations=observation_json)
    client = await aiohttp_client(app)
    nws = SimpleNWS(*LATLON, USERID, client)
    with pytest.raises(NwsError):
        await nws.update_observation()
    await nws.set_station(STATION)
    await nws.update_observation()
    observation = nws.observation
    assert observation
    assert observation["temperature"] == 10
    assert observation["dewpoint"] == 10
    assert observation["relativeHumidity"] == 10
    assert observation["windDirection"] == 10
    assert observation["visibility"] == 10000
    assert observation["seaLevelPressure"] == 100000
    assert observation["windSpeed"] == 36  # converted to km_gr
    assert observation["iconTime"] == "day"
    assert observation["windGust"] == 36  # same
    assert observation["iconWeather"][0][0] == "A few clouds"
    assert observation["iconWeather"][0][1] is None
예제 #21
0
async def test_forecast_all(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    await raw_data.raw_forecast_all(WFO, X, Y, client, USERID)
예제 #22
0
async def test_gridpoints_forecaat_hourly(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    await raw_data.raw_gridpoints_forecast_hourly(WFO, X, Y, client, USERID)
예제 #23
0
async def test_alerts_active_zone(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    await raw_data.raw_alerts_active_zone(ZONE, client, USERID)
예제 #24
0
async def test_points(aiohttp_client, loop, mock_urls):
    app = setup_app()
    client = await aiohttp_client(app)
    await raw_data.raw_points(*LATLON, client, USERID)