Exemple #1
0
async def test_nws_response(aiohttp_client, loop, obs_url, station_url, fore_url):
    app = aiohttp.web.Application()
    app.router.add_get("/obs", obs)
    app.router.add_get("/stations", stn)
    app.router.add_get("/fore", fore)
    client = await aiohttp_client(app)
    nws = pynws.Nws(client, latlon=LATLON)
    stations = await nws.stations()
    nws.station = stations[0]
    observations = await nws.observations()
    forecast = await nws.forecast()

    nws2 = pynws.Nws(client, station="STNA")
    observations2 = await nws2.observations()
Exemple #2
0
async def defaults():
    async with aiohttp.ClientSession() as session:
        nws = pynws.Nws(session, latlon=PHILLY, userid=USERID)
        stations = await nws.stations()
        nws.station = stations[0]
        observations = await nws.observations()
        forecast = await nws.forecast()
Exemple #3
0
async def test_alerts(aiohttp_client, loop, point_url, alerts_url):
    app = aiohttp.web.Application()
    app.router.add_get("/alerts", alerts)
    app.router.add_get("/point", point)
    client = await aiohttp_client(app)
    nws = pynws.Nws(client, latlon=(30, -85))

    assert await nws.alerts_forecast_zone()
    assert nws.forecast_zone == "FLZ015"

    nws = pynws.Nws(client, latlon=(30, -85))
    assert await nws.alerts_county_zone()
    assert nws.county_zone == "FLC037"

    nws = pynws.Nws(client, latlon=(30, -85))
    assert await nws.alerts_fire_weather_zone()
    assert nws.fire_weather_zone == "FLZ015"
Exemple #4
0
async def test_nws_fail_stn(aiohttp_client, loop, obs_url, station_url, fore_url):
    app = aiohttp.web.Application()
    app.router.add_get("/obs", obs)
    app.router.add_get("/stations", stn)
    app.router.add_get("/fore", fore)
    client = await aiohttp_client(app)
    nws = pynws.Nws(client)
    with pytest.raises(pynws.NwsError):
        stations = await nws.stations()
Exemple #5
0
async def test_nws_fail_fore(aiohttp_client, loop, obs_url, station_url,
                             fore_url):
    app = aiohttp.web.Application()
    app.router.add_get('/obs', obs)
    app.router.add_get('/stations', stn)
    app.router.add_get('/fore', fore)
    client = await aiohttp_client(app)
    nws = pynws.Nws(client)
    with pytest.raises(pynws.NwsError):
        stations = await nws.forecast()
Exemple #6
0
async def test_nws_grid_forecast(aiohttp_client, loop, point_url, grid_forecast_url):
    app = aiohttp.web.Application()
    app.router.add_get("/grid_forecast", grid_forecast)
    app.router.add_get("/point", point)
    client = await aiohttp_client(app)
    nws = pynws.Nws(client, latlon=(30, -85))

    assert await nws.grid_forecast()

    assert nws.wfo == "TAE"
    assert nws.x == 59
    assert nws.y == 64
Exemple #7
0
async def test_nws_response_no_obs(
    aiohttp_client, loop, obs_url, station_url, fore_url
):
    app = aiohttp.web.Application()
    app.router.add_get("/obs", no_obs)
    app.router.add_get("/stations", stn)
    app.router.add_get("/fore", fore)
    client = await aiohttp_client(app)
    nws = pynws.Nws(client, latlon=LATLON)
    stations = await nws.stations()
    nws.station = stations[0]
    observations = await nws.observations()
    assert not observations
Exemple #8
0
async def test_nws_point_response(aiohttp_client, loop, point_url):
    app = aiohttp.web.Application()
    app.router.add_get("/point", point)
    client = await aiohttp_client(app)
    nws = pynws.Nws(client, latlon=(30, -85))

    await nws.get_pointdata()

    assert nws.wfo == "TAE"
    assert nws.x == 59
    assert nws.y == 64
    assert nws.forecast_zone == "FLZ015"
    assert nws.county_zone == "FLC037"
    assert nws.fire_weather_zone == "FLZ015"