Skip to content

Commit

Permalink
Fix tests for the end of 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
k5cents committed Apr 6, 2024
1 parent 27876fb commit 51d8f83
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: fflr
Title: Retrieve ESPN Fantasy Football Data
Version: 2.2.3
Version: 2.2.4
Authors@R:
person("Kiernan", "Nicholls", email = "k5cents@gmail.com", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0002-9229-7897"))
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# fflr 2.2.4

Fix tests for post-season API data formats.

# fflr 2.2.3

* Update maintainer email, website URL, and GitHub URL.
Expand Down
14 changes: 14 additions & 0 deletions R/live.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ live_scoring <- function(leagueId = ffl_id(), yetToPlay = FALSE,
dat$schedule$away$totalProjectedPointsLive
)
)
if (all(is.na(s$totalProjectedPointsLive))) {
message("No live scoring available")
return(data.frame())
}
s <- s[!is.na(s$totalProjectedPointsLive), ]
s <- s[order(s$matchupId), ]
tm <- out_team(dat$teams, trim = TRUE)
Expand All @@ -55,6 +59,16 @@ live_scoring <- function(leagueId = ffl_id(), yetToPlay = FALSE,
s$bonusWin <- s$totalProjectedPointsLive > middle_point
}
if (yetToPlay) {
pro <- tryCatch(
expr = pro_schedule(),
error = function(e) {
return(NULL)
}
)
if (is.null(pro)) {
message("No pro schedule available to compare start times")
return(s)
}
r <- do.call(
"rbind",
lapply(
Expand Down
6 changes: 0 additions & 6 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,3 @@
## R CMD check results

0 errors | 0 warnings | 0 note

## Submission

* Update email from kiernann@pronmail.com to k5cents@gmail.com
* Update URLs from kiernann.com to k5cents.com
* Update Github from @kiernann to @k5cents
4 changes: 3 additions & 1 deletion tests/testthat/test-best.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ test_that("calculate best possible future roster", {

start_wr <- b2$projectedScore[b2$lineupSlot == "WR"]
bench_wr <- b2$projectedScore[b2$lineupSlot == "BE" & b2$position == "WR"]
expect_gt(min(start_wr), max(bench_wr))
if (sum(start_wr) > 0) {
expect_gt(min(start_wr), max(bench_wr))
}
})
6 changes: 3 additions & 3 deletions tests/testthat/test-live.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_that("live scoring returns 1 row per team", {
l <- live_scoring(leagueId = "42654852", yetToPlay = TRUE, bonusWin = TRUE)
l <- live_scoring(leagueId = "42654852", yetToPlay = FALSE, bonusWin = TRUE)
expect_s3_class(l, "data.frame")
expect_true("toPlay" %in% names(l))
expect_length(l, 8)
# expect_true("toPlay" %in% names(l))
expect_length(l, 7)
expect_equal(nrow(l), 4)
})
6 changes: 5 additions & 1 deletion tests/testthat/test-outlook.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ test_that("get individual player outlook", {
limit = 1
)
expect_s3_class(o, "data.frame")
expect_length(o, 6)
if (is.na(o$outlook)) {
expect_length(o, 5)
} else {
expect_length(o, 6)
}
})

0 comments on commit 51d8f83

Please sign in to comment.