File: test-all.R

package info (click to toggle)
r-cran-covid19us 0.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 232 kB
  • sloc: sh: 13; makefile: 2
file content (68 lines) | stat: -rw-r--r-- 1,752 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
test_that("get_states_daily works", {

  skip("Skip on Debian-CI")

  # Many rows
  full <- get_states_daily()

  # One state
  ct <- get_states_daily("CT")

  # One one state one date
  specific <- get_states_daily("NY", "2020-03-17")

  # Zero rows
  too_early <- get_states_daily(date = "2019-08-25")

  if (nrow(full) > 0) expect_gte(ncol(full), 7)
  if (nrow(ct) > 0) expect_gte(ncol(ct), 7)
  if (nrow(specific) > 0) expect_gte(ncol(specific), 7)

  if (nrow(full) > 0) expect_gte(nrow(full), 500)
  if (nrow(ct) > 0) expect_gte(nrow(ct), 10)
  if (nrow(specific) > 0) expect_equal(nrow(specific), 1)
  expect_equal(nrow(too_early), 0)
})

test_that("other funs work", {
  states_current <- get_states_current()

  if (nrow(states_current) > 0) {
    expect_is(
      c(
        states_current$last_update,
        states_current$check_time
      ),
      "POSIXct"
    )
  }

  states_info <- get_states_info()
  if (nrow(states_info) > 0) {
    expect_gte(ncol(states_info), 6)
  }

  us_current <- get_us_current()
  if (nrow(us_current) > 0) expect_equal(nrow(us_current), 1)

  us_daily <- get_us_daily()
  if (nrow(us_daily) > 0) expect_gte(nrow(us_daily), 10)

  counties_info <- get_counties_info()
  if (nrow(counties_info) > 0) {
    expect_gte(length(unique(counties_info$state)), 3)
  }

  urls <- get_tracker_urls()
  if (nrow(urls) > 0) expect_gte(ncol(urls), 5)

  refresh <- refresh_covid19us()
  if (nrow(refresh) > 0) expect_gte(ncol(refresh), 5)

  refresh_names <- c("date", "location", "location_type", "location_code", "location_code_type", "data_type", "value")

  if (nrow(refresh) > 0) expect_true(all(refresh_names %in% names(refresh)))

  info <- get_info_covid19us()
  if (nrow(info) > 0) expect_gte(ncol(info), 5)
})