tests/testthat/test-wnba_boxscoreusagev3.R

test_that("WNBA Boxscore Usage V3", {
  skip_on_cran()
  skip_on_ci()
  skip_wnba_stats_test()

  x <- wnba_boxscoreusagev3(game_id = "1022200034")

  if (length(x) == 0 || is.null(x[[1]]) || !is.data.frame(x[[1]]) || nrow(x[[1]]) == 0) {
    fail("No rows returned from endpoint at test time")
    return(invisible(NULL))
  }

  cols_x1 <- c(
    "game_id",
    "away_team_id",
    "home_team_id",
    "team_id",
    "team_name",
    "team_city",
    "team_tricode",
    "team_slug",
    "person_id",
    "first_name",
    "family_name",
    "name_i",
    "player_slug",
    "position",
    "comment",
    "jersey_num",
    "minutes",
    "usage_percentage",
    "percentage_field_goals_made",
    "percentage_field_goals_attempted",
    "percentage_three_pointers_made",
    "percentage_three_pointers_attempted",
    "percentage_free_throws_made",
    "percentage_free_throws_attempted",
    "percentage_rebounds_offensive",
    "percentage_rebounds_defensive",
    "percentage_rebounds_total",
    "percentage_assists",
    "percentage_turnovers",
    "percentage_steals",
    "percentage_blocks",
    "percentage_blocks_allowed",
    "percentage_personal_fouls",
    "percentage_personal_fouls_drawn",
    "percentage_points"
  )

  cols_x2 <- cols_x1

  cols_x3 <- c(
    "game_id",
    "away_team_id",
    "home_team_id",
    "team_id",
    "team_name",
    "team_city",
    "team_tricode",
    "team_slug",
    "minutes",
    "usage_percentage",
    "percentage_field_goals_made",
    "percentage_field_goals_attempted",
    "percentage_three_pointers_made",
    "percentage_three_pointers_attempted",
    "percentage_free_throws_made",
    "percentage_free_throws_attempted",
    "percentage_rebounds_offensive",
    "percentage_rebounds_defensive",
    "percentage_rebounds_total",
    "percentage_assists",
    "percentage_turnovers",
    "percentage_steals",
    "percentage_blocks",
    "percentage_blocks_allowed",
    "percentage_personal_fouls",
    "percentage_personal_fouls_drawn",
    "percentage_points"
  )

  cols_x4 <- cols_x3

  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")
  expect_in(sort(cols_x4), sort(colnames(x[[4]])))
  expect_s3_class(x[[4]], "data.frame")

  Sys.sleep(3)

})

Try the wehoop package in your browser

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

wehoop documentation built on Aug. 25, 2026, 1:06 a.m.