You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.6 KiB

2 years ago
3 years ago
6 years ago
2 years ago
  1. context("new API functionality")
  2. test_that("New API works", {
  3. expect_that(age_group_distribution(years=2017), is_a("data.frame"))
  4. expect_that(geographic_spread(years=2017), is_a("data.frame"))
  5. expect_that(state_data_providers(), is_a("data.frame"))
  6. expect_that(hospitalizations("flusurv", years=2017), is_a("data.frame"))
  7. expect_that(hospitalizations("eip", years=2017), is_a("data.frame"))
  8. expect_that(hospitalizations("eip", "Colorado", years=2017), is_a("data.frame"))
  9. expect_that(hospitalizations("ihsp", years=2017), is_a("data.frame"))
  10. expect_that(hospitalizations("ihsp", "Oklahoma", years=2017), is_a("data.frame"))
  11. skip_on_cran()
  12. nat_dat <- ilinet(region="national", years=1997:2018)
  13. expect_equal(unique(diff(nat_dat$week_start)), 7)
  14. expect_that(ilinet("national", years=2017), is_a("data.frame"))
  15. expect_that(ilinet("hhs", years=2017), is_a("data.frame"))
  16. expect_that(ilinet("census", years=2017), is_a("data.frame"))
  17. expect_that(ilinet("state", years=2017), is_a("data.frame"))
  18. expect_that(ili_weekly_activity_indicators(2017), is_a("data.frame"))
  19. expect_that(pi_mortality("national", years=2017), is_a("data.frame"))
  20. expect_that(pi_mortality("state", years=2017), is_a("data.frame"))
  21. expect_that(pi_mortality("region", years=2017), is_a("data.frame"))
  22. expect_that(surveillance_areas(), is_a("data.frame"))
  23. expect_that(who_nrevss("national", years=2017), is_a("list"))
  24. expect_that(who_nrevss("hhs", years=2017), is_a("list"))
  25. expect_that(who_nrevss("census", years=2017), is_a("list"))
  26. expect_that(who_nrevss("state", years=2017), is_a("list"))
  27. expect_that(cdc_basemap("national"), is_a("sf"))
  28. expect_that(cdc_basemap("hhs"), is_a("sf"))
  29. expect_that(cdc_basemap("census"), is_a("sf"))
  30. expect_that(cdc_basemap("states"), is_a("sf"))
  31. expect_that(cdc_basemap("spread"), is_a("sf"))
  32. expect_that(cdc_basemap("surv"), is_a("sf"))
  33. m1 <- mmwr_week(as.Date("2017-03-01"))
  34. m2 <- mmwr_weekday(as.Date("2017-03-01"))
  35. expect_equal(m1$mmwr_year[1], 2017)
  36. expect_equal(m1$mmwr_week[1], 9)
  37. expect_equal(m1$mmwr_day[1], 4)
  38. expect_that(m2, is_a("factor"))
  39. expect_equal(as.character(m2), "Wednesday")
  40. expect_equal(mmwr_week_to_date(2016,10,3), structure(16868, class = "Date"))
  41. })
  42. context("old API functionality")
  43. test_that("Old API works", {
  44. expect_that(dim(get_flu_data("hhs", years=2015)), equals(c(520L, 15L)))
  45. skip_on_cran()
  46. expect_that(dim(get_state_data(2008)), equals(c(2494L, 8L)))
  47. invisible(get_flu_data())
  48. invisible(get_hosp_data())
  49. invisible(get_flu_data(data_source="all"))
  50. invisible(get_weekly_flu_report())
  51. })