tests/testthat/test-nba_commonplayerinfo.R

test_that("NBA Common Player Info", {
  skip_on_cran()
  skip_on_ci()
  skip_nba_stats_test()



  x <- nba_commonplayerinfo(league_id = "00", player_id = "2544")

  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")
  }

  cols_x1 <- c(
    "PERSON_ID",
    "FIRST_NAME",
    "LAST_NAME",
    "DISPLAY_FIRST_LAST",
    "DISPLAY_LAST_COMMA_FIRST",
    "DISPLAY_FI_LAST",
    "PLAYER_SLUG",
    "BIRTHDATE",
    "SCHOOL",
    "COUNTRY",
    "LAST_AFFILIATION",
    "HEIGHT",
    "WEIGHT",
    "SEASON_EXP",
    "JERSEY",
    "POSITION",
    "ROSTERSTATUS",
    "GAMES_PLAYED_CURRENT_SEASON_FLAG",
    "TEAM_ID",
    "TEAM_NAME",
    "TEAM_ABBREVIATION",
    "TEAM_CODE",
    "TEAM_CITY",
    "PLAYERCODE",
    "FROM_YEAR",
    "TO_YEAR",
    "DLEAGUE_FLAG",
    "NBA_FLAG",
    "GAMES_PLAYED_FLAG",
    "DRAFT_YEAR",
    "DRAFT_ROUND",
    "DRAFT_NUMBER",
    "GREATEST_75_FLAG"
  )
  cols_x2 <- c(
    "PLAYER_ID",
    "PLAYER_NAME",
    "TimeFrame",
    "PTS",
    "AST",
    "REB",
    "PIE"
  )
  cols_x3 <- c(
    "SEASON_ID"
  )
  expect_in(sort(cols_x1), sort(colnames(x[[1]])))
  expect_s3_class(x[[1]], "data.frame")
  expect_in(sort(cols_x2), sort(colnames(x[[2]])))
  expect_s3_class(x[[2]], "data.frame")
  expect_in(sort(cols_x3), sort(colnames(x[[3]])))
  expect_s3_class(x[[3]], "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.