Skip to content

Commit

Permalink
update testthat
Browse files Browse the repository at this point in the history
  • Loading branch information
saiemgilani committed Jun 10, 2022
1 parent 4c02a4a commit 285993a
Show file tree
Hide file tree
Showing 47 changed files with 90 additions and 141 deletions.
1 change: 0 additions & 1 deletion tests/testthat/test-cfbd_betting_lines.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Betting Lines")



Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-cfbd_calendar.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Calendar")

cols <- c(
"season", "week", "season_type",
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-cfbd_coaches.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Coaches")

cols <- c(
"first_name", "last_name","hire_date", "school", "year", "games",
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-cfbd_conferences.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Conferences")


cols <- c("conference_id", "name", "long_name", "abbreviation", "classification")
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-cfbd_draft_picks.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
context("NFL Draft Picks")


cols <- c(
"college_athlete_id", "nfl_athlete_id",
"college_id","college_team","college_conference",
"nfl_team","year","overall","round","pick","name", "position",
"height", "weight",
"height", "weight",
"pre_draft_ranking", "pre_draft_position_ranking", "pre_draft_grade",
"hometown_info_city", "hometown_info_state", "hometown_info_country","hometown_info_latitude",
"hometown_info_longitude", "hometown_info_county_fips"
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-cfbd_draft_positions.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("NFL Draft Positions")


cols <- c(
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-cfbd_draft_teams.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("NFL Draft Teams")


cols <- c(
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-cfbd_drives.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Drives")
cols <- c(
"offense", "offense_conference", "defense", "defense_conference",
"game_id", "drive_id", "drive_number", "scoring", "start_period", "start_yardline",
Expand Down
25 changes: 12 additions & 13 deletions tests/testthat/test-cfbd_game_box_advanced.R
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
context("CFB Game Box Advanced")



cols1 <- c("stat", "team1", "team2")
cols2 <- c(
"team", "ppa_plays",
"ppa_overall_total", "ppa_overall_quarter1", "ppa_overall_quarter2", "ppa_overall_quarter3", "ppa_overall_quarter4",
"team", "ppa_plays",
"ppa_overall_total", "ppa_overall_quarter1", "ppa_overall_quarter2", "ppa_overall_quarter3", "ppa_overall_quarter4",
"ppa_passing_total", "ppa_passing_quarter1", "ppa_passing_quarter2", "ppa_passing_quarter3", "ppa_passing_quarter4",
"ppa_rushing_total", "ppa_rushing_quarter1", "ppa_rushing_quarter2", "ppa_rushing_quarter3", "ppa_rushing_quarter4",
"cumulative_ppa_plays", "cumulative_ppa_overall_total", "cumulative_ppa_overall_quarter1", "cumulative_ppa_overall_quarter2",
"ppa_rushing_total", "ppa_rushing_quarter1", "ppa_rushing_quarter2", "ppa_rushing_quarter3", "ppa_rushing_quarter4",
"cumulative_ppa_plays", "cumulative_ppa_overall_total", "cumulative_ppa_overall_quarter1", "cumulative_ppa_overall_quarter2",
"cumulative_ppa_overall_quarter3", "cumulative_ppa_overall_quarter4",
"cumulative_ppa_passing_total", "cumulative_ppa_passing_quarter1", "cumulative_ppa_passing_quarter2",
"cumulative_ppa_passing_quarter3", "cumulative_ppa_passing_quarter4", "cumulative_ppa_rushing_total",
"cumulative_ppa_rushing_quarter1", "cumulative_ppa_rushing_quarter2", "cumulative_ppa_rushing_quarter3",
"cumulative_ppa_rushing_quarter4", "success_rates_overall_total",
"success_rates_overall_quarter1", "success_rates_overall_quarter2", "success_rates_overall_quarter3", "success_rates_overall_quarter4",
"cumulative_ppa_passing_total", "cumulative_ppa_passing_quarter1", "cumulative_ppa_passing_quarter2",
"cumulative_ppa_passing_quarter3", "cumulative_ppa_passing_quarter4", "cumulative_ppa_rushing_total",
"cumulative_ppa_rushing_quarter1", "cumulative_ppa_rushing_quarter2", "cumulative_ppa_rushing_quarter3",
"cumulative_ppa_rushing_quarter4", "success_rates_overall_total",
"success_rates_overall_quarter1", "success_rates_overall_quarter2", "success_rates_overall_quarter3", "success_rates_overall_quarter4",
"success_rates_standard_downs_total", "success_rates_standard_downs_quarter1", "success_rates_standard_downs_quarter2", "success_rates_standard_downs_quarter3", "success_rates_standard_downs_quarter4",
"success_rates_passing_downs_total", "success_rates_passing_downs_quarter1", "success_rates_passing_downs_quarter2", "success_rates_passing_downs_quarter3", "success_rates_passing_downs_quarter4",
"explosiveness_overall_total", "explosiveness_overall_quarter1", "explosiveness_overall_quarter2", "explosiveness_overall_quarter3", "explosiveness_overall_quarter4",
"success_rates_passing_downs_total", "success_rates_passing_downs_quarter1", "success_rates_passing_downs_quarter2", "success_rates_passing_downs_quarter3", "success_rates_passing_downs_quarter4",
"explosiveness_overall_total", "explosiveness_overall_quarter1", "explosiveness_overall_quarter2", "explosiveness_overall_quarter3", "explosiveness_overall_quarter4",
"rushing_power_success", "rushing_stuff_rate", "rushing_line_yds", "rushing_line_yds_avg", "rushing_second_lvl_yds", "rushing_second_lvl_yds_avg",
"rushing_open_field_yds", "rushing_open_field_yds_avg", "havoc_total", "havoc_front_seven", "havoc_db", "scoring_opps_opportunities", "scoring_opps_points", "scoring_opps_pts_per_opp", "field_pos_avg_start", "field_pos_avg_starting_predicted_pts")
test_that("CFB Game Box Advanced", {
skip_on_cran()
x <- cfbd_game_box_advanced(game_id = 401012356)

y <- cfbd_game_box_advanced(game_id = 401110720)
expect_equal(nrow(x), 2)
expect_equal(nrow(y), 2)
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-cfbd_game_info.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Game Info")


cols <- c(
Expand All @@ -19,7 +18,7 @@ cols <- c(
test_that("CFB Game Info", {
skip_on_cran()
x <- cfbd_game_info(2019, week = 1, conference = "ACC")

y <- cfbd_game_info(2018, week = 4, conference = "Ind")
expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-cfbd_game_media.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Game Media")



Expand All @@ -11,7 +10,7 @@ cols <- c(
test_that("CFB Game Media", {
skip_on_cran()
x <- cfbd_game_media(2019, week = 1, conference = "ACC")

y <- cfbd_game_media(2018, week = 4, conference = "Ind")
expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
Expand Down
15 changes: 7 additions & 8 deletions tests/testthat/test-cfbd_game_player_stats.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
context("CFB Game Player Stats")


test_that("CFB Game Player Stats", {
skip_on_cran()
cols <- c(
"game_id", "team", "conference", "home_away", "points", "category",
"athlete_id", "name", "c_att", "yds", "avg", "td", "int", "qbr", "car",
"long", "rec", "no", "fg", "pct", "xp", "pts", "tb",
"game_id", "team", "conference", "home_away", "points", "category",
"athlete_id", "name", "c_att", "yds", "avg", "td", "int", "qbr", "car",
"long", "rec", "no", "fg", "pct", "xp", "pts", "tb",
"in_20", "fum", "lost", "tot", "solo", "sacks", "tfl", "pd", "qb_hur")

x <- cfbd_game_player_stats(2018, week = 15, conference = 'Ind')

y <- cfbd_game_player_stats(2013, week = 1, team = "Florida State", category = 'passing')

z <- cfbd_game_player_stats(2013, week = 1, team = "Florida State")
expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
expect_equal(colnames(z), cols)
expect_s3_class(x, "data.frame")
expect_s3_class(y, "data.frame")
expect_s3_class(z, "data.frame")
})
})
3 changes: 1 addition & 2 deletions tests/testthat/test-cfbd_game_records.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Game Records")



Expand All @@ -13,7 +12,7 @@ cols <- c(
test_that("CFB Game Records", {
skip_on_cran()
x <- cfbd_game_records(2018, team = "Notre Dame")

y <- cfbd_game_records(2013, team = "Florida State")
expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-cfbd_game_team_stats.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Game Team Stats")
cols1 <- c("game_id", "school", "conference", "home_away","opponent","opponent_conference",
"points", "total_yards", "net_passing_yards",
"completion_attempts","passing_tds","yards_per_pass",
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-cfbd_game_weather.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Game Weather")


cols <- c(
Expand Down Expand Up @@ -29,7 +28,7 @@ context("CFB Game Weather")
test_that("CFB Game Info", {
skip_on_cran()
x <- cfbd_game_weather(2019, week = 1, conference = "ACC")

y <- cfbd_game_weather(2018, week = 4, conference = "Ind")
expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-cfbd_metrics_ppa_games.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Metrics PPA Games")


cols <- c(
Expand All @@ -11,7 +10,7 @@ cols <- c(
test_that("CFB Metrics PPA Games", {
skip_on_cran()
x <- cfbd_metrics_ppa_games(year = 2019, team = "TCU")

y <- cfbd_metrics_ppa_games(year = 2019, team = "Alabama", week = 11)
expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-cfbd_metrics_ppa_players_games.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Metrics PPA Games")


cols <- c(
Expand All @@ -9,7 +8,7 @@ cols <- c(
test_that("CFB Metrics PPA Games", {
skip_on_cran()
x <- cfbd_metrics_ppa_players_games(year = 2019, week = 4, team = "TCU")

y <- cfbd_metrics_ppa_players_games(year = 2019, team = "Alabama", week = 11)
expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-cfbd_metrics_ppa_players_season.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Metrics PPA Players Season")


cols <- c(
Expand All @@ -14,7 +13,7 @@ cols <- c(
test_that("CFB Metrics PPA Players Season", {
skip_on_cran()
x <- cfbd_metrics_ppa_players_season(year = 2019, team = "TCU")

y <- cfbd_metrics_ppa_players_season(year = 2019, team = "Alabama")
expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-cfbd_metrics_ppa_predicted.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
context("CFB Metrics PPA Predicted")

cols <- c("yard_line", "predicted_points")

test_that("CFB Metrics PPA Predicted", {

skip_on_cran()
x <- cfbd_metrics_ppa_predicted(down = 1, distance = 10)
y <- cfbd_metrics_ppa_predicted(down = 3, distance = 10)
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-cfbd_metrics_wp.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Metrics API Win Probability")


cols <- c(
Expand All @@ -10,7 +9,7 @@ cols <- c(
test_that("CFB Metrics API Win Probability", {
skip_on_cran()
x <- cfbd_metrics_wp(game_id = 401012356)

y <- cfbd_metrics_wp(game_id = 401110720)
expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
Expand Down
5 changes: 2 additions & 3 deletions tests/testthat/test-cfbd_metrics_wp_pregame.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Metrics API Pre-Game Win Probability")

cols <- c(
"season", "season_type", "week", "game_id",
Expand All @@ -7,9 +6,9 @@ cols <- c(

test_that("CFB Metrics API Pre-Game Win Probability", {
skip_on_cran()

x <- cfbd_metrics_wp_pregame(year = 2019, week = 9, team = "Texas A&M")

y <- cfbd_metrics_wp_pregame(year = 2017, week = 8, team = "TCU")
expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-cfbd_play_stats_player.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Play Stats - Player")


cols <- c(
Expand All @@ -23,7 +22,7 @@ cols <- c(
test_that("CFB Play Stats - Player", {
skip_on_cran()
x <- cfbd_play_stats_player(game_id = 401012356)

y <- cfbd_play_stats_player(game_id = 401110720)
expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-cfbd_play_stats_types.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Play Stats Types")


cols <- c("play_stat_type_id", "name")
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-cfbd_play_types.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Play Types")


cols <- c("play_type_id", "text", "abbreviation")
Expand Down
5 changes: 2 additions & 3 deletions tests/testthat/test-cfbd_player_info.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Player Info")


cols <- c(
Expand All @@ -10,9 +9,9 @@ cols <- c(
test_that("CFB Player Info", {
skip_on_cran()
x <- cfbd_player_info(search_term = "James", position = "DB", team = "Florida State", year = 2017)

y <- cfbd_player_info(search_term = "Lawrence", team = "Clemson")

w <- cfbd_player_info(search_term = "Duggan")
expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-cfbd_player_returning.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Player Returning")

cols <- c(
"season", "team", "conference", "total_ppa", "total_passing_ppa",
Expand All @@ -8,7 +7,7 @@ cols <- c(
)

test_that("CFB Player Returning", {

skip_on_cran()
x <- cfbd_player_returning(year = 2020, team = "Florida State")
expect_equal(colnames(x), cols)
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-cfbd_player_usage.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Player Usage")


cols <- c(
Expand Down
9 changes: 4 additions & 5 deletions tests/testthat/test-cfbd_rankings.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Poll Rankings")


cols <- c(
Expand All @@ -10,18 +9,18 @@ cols <- c(
test_that("CFB Poll Rankings", {
skip_on_cran()
x <- cfbd_rankings(year = 2019, week = 12)

y <- cfbd_rankings(year = 2018, week = 14)

z <- cfbd_rankings(year = 2013, season_type = "postseason")
first_team_AP_13 <- z %>%
filter(.data$poll == "AP Top 25" & .data$rank == 1) %>%
select(.data$school)

first_team_coaches_13 <- z %>%
filter(.data$poll == "Coaches Poll" & .data$rank == 1) %>%
select(.data$school)

expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
expect_equal(colnames(z), cols)
Expand Down
8 changes: 3 additions & 5 deletions tests/testthat/test-cfbd_ratings_elo.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
context("CFB Elo ratings")

cols <- c("year", "team", "conference", "elo")

test_that("CFB Elo ratings", {
skip_on_cran()
x <- cfbd_ratings_elo(year = 2019)

y <- cfbd_ratings_elo(year = 2012, conference = "SEC")

z <- cfbd_ratings_elo(year = 2016, conference = "ACC")

expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
expect_equal(colnames(z), cols)
Expand Down
7 changes: 3 additions & 4 deletions tests/testthat/test-cfbd_ratings_sp.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
context("CFB Ratings - Bill C.'s SP+")

cols <- c(
"year", "team",
Expand All @@ -15,11 +14,11 @@ cols <- c(
test_that("CFB Ratings - Bill C.'s SP+", {
skip_on_cran()
x <- cfbd_ratings_sp(year = 2019)

y <- cfbd_ratings_sp(team = "Texas A&M")

z <- cfbd_ratings_sp(year = 2019, team = "LSU")

expect_equal(colnames(x), cols)
expect_equal(colnames(y), cols)
expect_equal(colnames(z), cols)
Expand Down
Loading

0 comments on commit 285993a

Please sign in to comment.