tests/testthat/test-weather_forecast_hourly.R

test_that("weather forecast_hourly works", {
  # Set dummy key
  set_key("dummy_api_key")

  # Load package example data
  data(poi)

  # Test with API response mock
  with_mock(
    "hereR:::.async_request" = function(url, rps) {
      hereR:::mock$weather_forecast_hourly_response
    },
    weather_forecast_hourly <- weather(poi = poi, product = "forecast_hourly"),

    # Tests
    expect_equal(any(sf::st_geometry_type(weather_forecast_hourly) != "POINT"), FALSE),
    expect_equal(nrow(weather_forecast_hourly), nrow(poi))
  )
})

Try the hereR package in your browser

Any scripts or data that you put into this service are public.

hereR documentation built on Sept. 18, 2023, 5:21 p.m.