Skip to content

Commit

Permalink
version lock tests and vignette cache
Browse files Browse the repository at this point in the history
  • Loading branch information
tanho63 committed Nov 9, 2021
1 parent 296c4ca commit e96a26c
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 74 deletions.
8 changes: 4 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ eval <- TRUE
tryCatch(expr = {
download.file("https://github.com/ffverse/ffscrapr-tests/archive/main.zip","f.zip")
download.file("https://github.com/ffverse/ffscrapr-tests/archive/1.4.7.zip","f.zip")
unzip('f.zip', exdir = ".")
httptest::.mockPaths(new = "ffscrapr-tests-main")},
httptest::.mockPaths(new = "ffscrapr-tests-1.4.7")},
warning = function(e) eval <<- FALSE,
error = function(e) eval <<- FALSE)
Expand All @@ -42,7 +42,7 @@ httptest::use_mock_api()
[![CRAN status](https://img.shields.io/cran/v/ffscrapr?style=flat-square&logo=R&label=CRAN)](https://CRAN.R-project.org/package=ffscrapr)
[![Dev status](https://img.shields.io/github/r-package/v/ffverse/ffscrapr/dev?label=dev&style=flat-square&logo=github)](https://ffscrapr.ffverse.com/dev/)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-green.svg?style=flat-square)](https://lifecycle.r-lib.org/articles/stages.html)
[![Codecov test coverage](https://img.shields.io/codecov/c/github/ffverse/ffscrapr?label=codecov&style=flat-square&logo=codecov)](https://codecov.io/gh/ffverse/ffscrapr?branch=main)
[![Codecov test coverage](https://img.shields.io/codecov/c/github/ffverse/ffscrapr?label=codecov&style=flat-square&logo=codecov)](https://app.codecov.io/gh/ffverse/ffscrapr?branch=main)
[![R build status](https://img.shields.io/github/workflow/status/ffverse/ffscrapr/R-CMD-check?label=R%20check&style=flat-square&logo=github)](https://github.com/ffverse/ffscrapr/actions)
[![API status](https://img.shields.io/github/workflow/status/ffverse/ffscrapr/Test%20APIs?label=API%20check&style=flat-square&logo=github)](https://github.com/ffverse/ffscrapr/actions)
[![nflverse discord](https://img.shields.io/discord/789805604076126219?color=7289da&label=nflverse%20discord&logo=discord&logoColor=fff&style=flat-square)](https://discord.com/invite/5Er2FBnnQa)
Expand Down Expand Up @@ -120,5 +120,5 @@ The APIs and data accessed by this package belong to their respective owners, an

```{r include = FALSE}
httptest::stop_mocking()
unlink(c("ffscrapr-tests-main","f.zip"), recursive = TRUE, force = TRUE)
unlink(c("ffscrapr-tests-1.4.7","f.zip"), recursive = TRUE, force = TRUE)
```
41 changes: 1 addition & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ status](https://img.shields.io/github/r-package/v/ffverse/ffscrapr/dev?label=dev
[![Lifecycle:
stable](https://img.shields.io/badge/lifecycle-stable-green.svg?style=flat-square)](https://lifecycle.r-lib.org/articles/stages.html)
[![Codecov test
coverage](https://img.shields.io/codecov/c/github/ffverse/ffscrapr?label=codecov&style=flat-square&logo=codecov)](https://codecov.io/gh/ffverse/ffscrapr?branch=main)
coverage](https://img.shields.io/codecov/c/github/ffverse/ffscrapr?label=codecov&style=flat-square&logo=codecov)](https://app.codecov.io/gh/ffverse/ffscrapr?branch=main)
[![R build
status](https://img.shields.io/github/workflow/status/ffverse/ffscrapr/R-CMD-check?label=R%20check&style=flat-square&logo=github)](https://github.com/ffverse/ffscrapr/actions)
[![API
Expand Down Expand Up @@ -62,51 +62,12 @@ ssb <- ff_connect(platform = "mfl", league_id = "54040", season = 2020)

# Get a summary of league settings
ff_league(ssb) %>% str()
#> tibble [1 x 17] (S3: tbl_df/tbl/data.frame)
#> $ league_id : chr "54040"
#> $ league_name : chr "The Super Smash Bros Dynasty League"
#> $ season : int 2020
#> $ league_type : chr NA
#> $ franchise_count : num 14
#> $ qb_type : chr "1QB"
#> $ idp : logi FALSE
#> $ scoring_flags : chr "0.5_ppr, TEPrem, PP1D"
#> $ best_ball : logi FALSE
#> $ salary_cap : logi FALSE
#> $ player_copies : num 1
#> $ years_active : chr "2018-2021"
#> $ qb_count : chr "1"
#> $ roster_size : num 33
#> $ league_depth : num 462
#> $ draft_type : chr "email draft"
#> $ draft_player_pool: chr "Both"

# Get rosters
ff_rosters(ssb)
#> # A tibble: 442 x 11
#> franchise_id franchise_name player_id player_name pos team age
#> <chr> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 0001 Team Pikachu 13189 Engram, Evan TE NYG 27
#> 2 0001 Team Pikachu 11680 Landry, Jarvis WR CLE 28.8
#> 3 0001 Team Pikachu 13645 Smith, Tre'Quan WR NOS 25.7
#> 4 0001 Team Pikachu 12110 Brate, Cameron TE TBB 30.2
#> 5 0001 Team Pikachu 13168 Reynolds, Josh WR LAR 26.5
#> # ... with 437 more rows, and 4 more variables: roster_status <chr>,
#> # drafted <chr>, draft_year <chr>, draft_round <chr>

# Get transactions
ff_transactions(ssb)
#> # A tibble: 1,145 x 12
#> timestamp type type_desc franchise_id franchise_name
#> <dttm> <chr> <chr> <chr> <chr>
#> 1 2021-02-12 14:32:39 TRADE traded_away 0008 Team Bowser
#> 2 2021-02-12 14:32:39 TRADE traded_for 0008 Team Bowser
#> 3 2021-02-12 14:32:39 TRADE traded_for 0008 Team Bowser
#> 4 2021-02-12 14:32:39 TRADE traded_for 0008 Team Bowser
#> 5 2021-02-12 14:32:39 TRADE traded_for 0008 Team Bowser
#> # ... with 1,140 more rows, and 7 more variables: player_id <chr>,
#> # player_name <chr>, pos <chr>, team <chr>, bbid_spent <dbl>,
#> # trade_partner <chr>, comments <chr>
```

Platform-specific guides on getting started with ffscrapr are here:
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ skip <- FALSE
if (download_mock) {
tryCatch(
expr = {
download.file("https://github.com/ffverse/ffscrapr-tests/archive/main.zip", "f.zip")
download.file("https://github.com/ffverse/ffscrapr-tests/archive/1.4.7.zip", "f.zip")
unzip("f.zip", exdir = ".")

httptest::.mockPaths(new = "ffscrapr-tests-main")
httptest::.mockPaths(new = "ffscrapr-tests-1.4.7")

withr::defer(
unlink(c("ffscrapr-tests-main", "f.zip"), recursive = TRUE, force = TRUE),
unlink(c("ffscrapr-tests-1.4.7", "f.zip"), recursive = TRUE, force = TRUE),
testthat::teardown_env()
)
},
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-ff_scoringhistory.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ with_mock_api({
if (!identical(Sys.getenv("MOCK_BYPASS"), "true")) {
testthat::local_mock(
nflfastr_weekly = function(seasons, type) {
if(type == "offense") return(readRDS("ffscrapr-tests-main/gh_nflfastr/player_stats.rds"))
if(type == "kicking") return(readRDS("ffscrapr-tests-main/gh_nflfastr/kicker_stats.rds"))
if(type == "offense") return(readRDS("ffscrapr-tests-1.4.7/gh_nflfastr/player_stats.rds"))
if(type == "kicking") return(readRDS("ffscrapr-tests-1.4.7/gh_nflfastr/kicker_stats.rds"))
},
nflfastr_rosters = function(seasons) {
purrr::map_df(seasons, ~ readRDS(glue::glue("ffscrapr-tests-main/gh_nflfastr/roster_{.x}.rds")))
purrr::map_df(seasons, ~ readRDS(glue::glue("ffscrapr-tests-1.4.7/gh_nflfastr/roster_{.x}.rds")))
}
)
}
Expand Down
6 changes: 3 additions & 3 deletions vignettes/espn_basics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ eval <- TRUE
tryCatch(expr = {
download.file("https://github.com/ffverse/ffscrapr-tests/archive/main.zip","f.zip")
download.file("https://github.com/ffverse/ffscrapr-tests/archive/1.4.7.zip","f.zip")
unzip('f.zip', exdir = ".")
httptest::.mockPaths(new = "ffscrapr-tests-main")},
httptest::.mockPaths(new = "ffscrapr-tests-1.4.7")},
warning = function(e) eval <<- FALSE,
error = function(e) eval <<- FALSE)
Expand Down Expand Up @@ -160,6 +160,6 @@ In this vignette, I've used only a few functions: ff_connect, ff_league, ff_rost
```{r include = FALSE}
httptest::stop_mocking()
unlink(c("ffscrapr-tests-main","f.zip"), recursive = TRUE, force = TRUE)
unlink(c("ffscrapr-tests-1.4.7","f.zip"), recursive = TRUE, force = TRUE)
```

6 changes: 3 additions & 3 deletions vignettes/espn_getendpoint.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ eval <- TRUE
tryCatch(expr = {
download.file("https://github.com/ffverse/ffscrapr-tests/archive/main.zip","f.zip")
download.file("https://github.com/ffverse/ffscrapr-tests/archive/1.4.7.zip","f.zip")
unzip('f.zip', exdir = ".")
httptest::.mockPaths(new = "ffscrapr-tests-main")},
httptest::.mockPaths(new = "ffscrapr-tests-1.4.7")},
warning = function(e) eval <<- FALSE,
error = function(e) eval <<- FALSE)
Expand Down Expand Up @@ -155,5 +155,5 @@ Many of the API endpoints are being researched in other languages and you might
```{r include = FALSE}
httptest::stop_mocking()
unlink(c("ffscrapr-tests-main","f.zip"), recursive = TRUE, force = TRUE)
unlink(c("ffscrapr-tests-1.4.7","f.zip"), recursive = TRUE, force = TRUE)
```
6 changes: 3 additions & 3 deletions vignettes/fleaflicker_basics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ eval <- TRUE
tryCatch(expr = {
download.file("https://github.com/ffverse/ffscrapr-tests/archive/main.zip","f.zip")
download.file("https://github.com/ffverse/ffscrapr-tests/archive/1.4.7.zip","f.zip")
unzip('f.zip', exdir = ".")
httptest::.mockPaths(new = "ffscrapr-tests-main")},
httptest::.mockPaths(new = "ffscrapr-tests-1.4.7")},
warning = function(e) eval <<- FALSE,
error = function(e) eval <<- FALSE)
Expand Down Expand Up @@ -162,6 +162,6 @@ In this vignette, I've used only a few functions: ff_connect, ff_league, ff_rost
```{r include = FALSE}
httptest::stop_mocking()
unlink(c("ffscrapr-tests-main","f.zip"), recursive = TRUE, force = TRUE)
unlink(c("ffscrapr-tests-1.4.7","f.zip"), recursive = TRUE, force = TRUE)
```

6 changes: 3 additions & 3 deletions vignettes/fleaflicker_getendpoint.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ eval <- TRUE
tryCatch(expr = {
download.file("https://github.com/ffverse/ffscrapr-tests/archive/main.zip","f.zip")
download.file("https://github.com/ffverse/ffscrapr-tests/archive/1.4.7.zip","f.zip")
unzip('f.zip', exdir = ".")
httptest::.mockPaths(new = "ffscrapr-tests-main")},
httptest::.mockPaths(new = "ffscrapr-tests-1.4.7")},
warning = function(e) eval <<- FALSE,
error = function(e) eval <<- FALSE)
Expand Down Expand Up @@ -123,6 +123,6 @@ From here, you can keep unravelling - including the "viewingActualPoints" and "v
```{r include = FALSE}
httptest::stop_mocking()
unlink(c("ffscrapr-tests-main","f.zip"), recursive = TRUE, force = TRUE)
unlink(c("ffscrapr-tests-1.4.7","f.zip"), recursive = TRUE, force = TRUE)
```

6 changes: 3 additions & 3 deletions vignettes/mfl_basics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ eval <- TRUE
tryCatch(expr = {
download.file("https://github.com/ffverse/ffscrapr-tests/archive/main.zip","f.zip")
download.file("https://github.com/ffverse/ffscrapr-tests/archive/1.4.7.zip","f.zip")
unzip('f.zip', exdir = ".")
httptest::.mockPaths(new = "ffscrapr-tests-main")},
httptest::.mockPaths(new = "ffscrapr-tests-1.4.7")},
warning = function(e) eval <<- FALSE,
error = function(e) eval <<- FALSE)
Expand Down Expand Up @@ -157,6 +157,6 @@ Now that you've gotten this far, why not check out some of the other possibiliti
```{r include = FALSE}
httptest::stop_mocking()
unlink(c("ffscrapr-tests-main","f.zip"), recursive = TRUE, force = TRUE)
unlink(c("ffscrapr-tests-1.4.7","f.zip"), recursive = TRUE, force = TRUE)
```

6 changes: 3 additions & 3 deletions vignettes/mfl_getendpoint.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ eval <- TRUE
tryCatch(expr = {
download.file("https://github.com/ffverse/ffscrapr-tests/archive/main.zip","f.zip")
download.file("https://github.com/ffverse/ffscrapr-tests/archive/1.4.7.zip","f.zip")
unzip('f.zip', exdir = ".")
httptest::.mockPaths(new = "ffscrapr-tests-main")},
httptest::.mockPaths(new = "ffscrapr-tests-1.4.7")},
warning = function(e) eval <<- FALSE,
error = function(e) eval <<- FALSE)
Expand Down Expand Up @@ -104,5 +104,5 @@ head(fog_tradebait)
```{r include = FALSE}
httptest::stop_mocking()
unlink(c("ffscrapr-tests-main","f.zip"), recursive = TRUE, force = TRUE)
unlink(c("ffscrapr-tests-1.4.7","f.zip"), recursive = TRUE, force = TRUE)
```
6 changes: 3 additions & 3 deletions vignettes/sleeper_basics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ eval <- TRUE
tryCatch(expr = {
download.file("https://github.com/ffverse/ffscrapr-tests/archive/main.zip","f.zip")
download.file("https://github.com/ffverse/ffscrapr-tests/archive/1.4.7.zip","f.zip")
unzip('f.zip', exdir = ".")
httptest::.mockPaths(new = "ffscrapr-tests-main")},
httptest::.mockPaths(new = "ffscrapr-tests-1.4.7")},
warning = function(e) eval <<- FALSE,
error = function(e) eval <<- FALSE)
Expand Down Expand Up @@ -167,6 +167,6 @@ In this vignette, I've used ~three functions: ff_connect, ff_league, and ff_rost
```{r include = FALSE}
httptest::stop_mocking()
unlink(c("ffscrapr-tests-main","f.zip"), recursive = TRUE, force = TRUE)
unlink(c("ffscrapr-tests-1.4.7","f.zip"), recursive = TRUE, force = TRUE)
```

6 changes: 3 additions & 3 deletions vignettes/sleeper_getendpoint.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ eval <- TRUE
tryCatch(expr = {
download.file("https://github.com/ffverse/ffscrapr-tests/archive/main.zip","f.zip")
download.file("https://github.com/ffverse/ffscrapr-tests/archive/1.4.7.zip","f.zip")
unzip('f.zip', exdir = ".")
httptest::.mockPaths(new = "ffscrapr-tests-main")},
httptest::.mockPaths(new = "ffscrapr-tests-1.4.7")},
warning = function(e) eval <<- FALSE,
error = function(e) eval <<- FALSE)
Expand Down Expand Up @@ -95,6 +95,6 @@ There - this means something to us now! As of this writing (2020-11-10), Kalen B
```{r include = FALSE, eval = eval}
httptest::stop_mocking()
unlink(c("ffscrapr-tests-main","f.zip"), recursive = TRUE, force = TRUE)
unlink(c("ffscrapr-tests-1.4.7","f.zip"), recursive = TRUE, force = TRUE)
```

0 comments on commit e96a26c

Please sign in to comment.