tests/testthat/test-get_afghan_regional_cases.R

source('./custom_tests/expect_colname.R')

test_that("get_afghan_regional_cases works as expected", {

  d <- get_afghan_regional_cases()
  expect_is(d, "data.frame")
  expect_is(d$date, "Date")
  expect_is(d$cases, "numeric")
  expect_is(d$deaths, "numeric")
  expect_is(d$recovered, "numeric")
  expect_is(d$region, "character")
  expect_true(all(d$country == "Afghanistan"))
})

test_that("get_afghan_regional_cases data source is unchanged", {

  base <- readr::read_csv("https://docs.google.com/spreadsheets/d/1F-AMEDtqK78EA6LYME2oOsWQsgJi4CT3V_G4Uo-47Rg/export?format=csv")

  expected_colnames = c("Province", "Cases", "Deaths", "Recoveries", "Active Cases", "Date")

  sapply(expected_colnames, expect_colname, colnames = colnames(base))

})
epiforecasts/NCoVUtils documentation built on June 26, 2020, 1:20 a.m.