tests/testthat/test-kp_box.R

test_that("KP - Get box score", {
  skip_on_cran()
  skip_on_ci()
  skip_kenpom_test()

  x <- kp_box(game_id = 1238, year = 2020)

  if (length(x) == 0 || is.null(x[[1]]) || !is.data.frame(x[[1]]) || nrow(x[[1]]) == 0) {
    skip("No rows returned from endpoint at test time")
  }
  x1 <- x[[1]]
  x2 <- x[[2]]
  x3 <- x[[3]]
  x4 <- x[[4]]

  cols_x1 <- c(
    "hgt",
    "wgt",
    "yr",
    "number",
    "player",
    "min",
    "o_rtg",
    "percent_ps",
    "pts",
    "fgm_2",
    "fga_2",
    "fgm_3",
    "fga_3",
    "ftm",
    "fta",
    "or",
    "dr",
    "a",
    "to",
    "blk",
    "stl",
    "pf",
    "team",
    "wp_note",
    "game_id",
    "year"
  )
  cols_x3 <- c(
    "team",
    "q1",
    "q2",
    "q3",
    "q4",
    "t"
  )
  cols_x4 <- c(
    "official_id",
    "official_name",
    "game_id",
    "year"
  )
  expect_in(cols_x1, colnames(x1))
  expect_s3_class(x1, "data.frame")
  expect_in(cols_x1, colnames(x2))
  expect_s3_class(x2, "data.frame")
  expect_in(cols_x3, colnames(x3))
  expect_s3_class(x3, "data.frame")
  expect_in(cols_x4, colnames(x4))
  expect_s3_class(x4, "data.frame")

  Sys.sleep(3)
})

Try the hoopR package in your browser

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

hoopR documentation built on Aug. 25, 2026, 9:07 a.m.