Repository navigation
Cleanly handle HTTP error messages, add stop_on_error and exclude arguments to app$snapshot
#324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0c3a0ae
Provide 'exclude' argument to `snapshot` to prevent specified items f…
937a413
- Fix excusion code
b4fdb43
Add tests for snapshot(exclude).
4208a3d
Add excludes to permit use of `renv` package.
303fb0f
Drop extraneous code.
37b103a
Cleanly handle server errors in `app$snapshot`, and add the argument …
27defae
Ditto.
dbb329b
Add 'stop_on_error' argument to app$snapshot. When TRUE, an error wi…
45c6018
Update DESCRIPTION and one test to make R CMD check happy.
d7d227c
WIP
hadley d6d822a
Merged origin/master into http-check
hadley 0b3dc0b
Merged origin/master into http-check
hadley dd14186
Consistently handle HTTP failures
hadley 14fbb79
Merge from upstream master.
c109897
Merge branch 'http-check' of https://github.com/rstudio/shinytest
2b11b38
Merge from upstream `http-check`.
ddfe3fd
Ignore files associated with local use of `renv`.
6a0a08b
Cleanup imports and ignore files
302f8be
Add `exclude` to `getAllValues`, add to relevant test, and update doc…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,6 @@ | |
| .Rhistory | ||
| .RData | ||
| docs | ||
| .Rprofile | ||
| /renv | ||
| /renv.lock | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| tests/testthat/example_test_dirs/mixed-toplevel/tests/testa.r | ||
| tests/testthat/example_test_dirs/nested/tests/shinytest/whatever.R |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,27 @@ | ||
| # Note: This queries the server | ||
| sd_getAllValues <- function(self, private, input, output, export) { | ||
| "!DEBUG sd_getAllValues" | ||
| url <- private$getTestSnapshotUrl(input, output, export, format = "rds") | ||
|
|
||
| sd_getAllValues <- function(self, private, input, output, export, | ||
| exclude=NULL, stop_on_error=TRUE) { | ||
| self$logEvent("Getting all values") | ||
| tmpfile <- tempfile("shinytest_values", fileext = ".rds") | ||
| req <- httr::GET(url) | ||
| if (req$status_code != 200) { | ||
| stop("Unable to fetch all values from server. Is target app running with options(shiny.testmode=TRUE?)") | ||
| } | ||
| "!DEBUG sd_getAllValues" | ||
|
|
||
| writeBin(req$content, tmpfile) | ||
| url <- private$getTestSnapshotUrl(input, output, export, format = "rds") | ||
| req <- httr_get(url, stop_on_error) | ||
|
|
||
| tmpfile <- tempfile() | ||
| on.exit(unlink(tmpfile)) | ||
| writeBin(req$content, tmpfile) | ||
| rObj <- readRDS(tmpfile) | ||
|
|
||
| # Remove any items specified in ignore | ||
| if(length(exclude)>0) | ||
| { | ||
| dropItems <- function(l, i) l[! names(l) %in% i] | ||
|
|
||
| rObj$input <- dropItems(rObj$input, exclude) | ||
| rObj$output <- dropItems(rObj$output, exclude) | ||
| rObj$export <- dropItems(rObj$export, exclude) | ||
| } | ||
|
|
||
| readRDS(tmpfile) | ||
| rObj | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| library(shiny) | ||
| ui <- fluidPage( | ||
| actionButton("quit", "quit") | ||
| ) | ||
| server <- function(input, output, session) { | ||
| observeEvent(input$quit, stopApp()) | ||
| } | ||
| shinyApp(ui, server) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| library(shiny) | ||
|
|
||
|
|
||
| ui <- fluidPage( | ||
| checkboxInput("chkbx", "Display Graph?", FALSE), | ||
| uiOutput("dynamic_output") | ||
| ) | ||
|
|
||
| server <- function(input, output) { | ||
| output$dynamic_output <- renderUI({ | ||
| if(!input$chkbx) { | ||
| return(NULL) | ||
| } | ||
| tagList( | ||
| sliderInput(inputId = "bins", label = "Number of bins:", min = 1, max = 50, value = 30), | ||
| plotOutput(outputId = "distPlot") | ||
| ) | ||
| }) | ||
|
|
||
| observe({ | ||
| str(reactiveValuesToList(input)) | ||
| }) | ||
|
|
||
| # will not execute until `input$bins` is available | ||
| # `input$bins` is not available until `chkbx` is checked | ||
| output$distPlot <- renderPlot({ | ||
| Sys.sleep(5) | ||
|
|
||
| x <- faithful$waiting | ||
| bins <- seq(min(x), max(x), length.out = input$bins + 1) | ||
| hist(x, breaks = bins, col = "#75AADB", border = "white", | ||
| xlab = "Waiting time to next eruption (in mins)", | ||
| main = "Histogram of waiting times") | ||
| }) | ||
| } | ||
|
|
||
| shinyApp(ui = ui, server = server) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementing the
excludearguments only involves this code block and adding theomitargument to thesd_snapshotandapp$snapshotfunction definitions and handoff.