Fleshing out mock session implementation

This commit is contained in:
trestletech
2019-10-18 14:52:19 -05:00
parent b16e74c203
commit 63ae62ef33
2 changed files with 86 additions and 161 deletions

View File

@@ -49,6 +49,7 @@ MockShinySession <- R6Class(
incrementBusyCount = function(){},
output = NULL,
input = NULL,
userData = NULL,
initialize = function() {
private$.input <- ReactiveValues$new(dedupe = FALSE, label = "input")
@@ -57,6 +58,8 @@ MockShinySession <- R6Class(
private$endedCBs <- Callbacks$new()
private$timer <- MockableTimerCallbacks$new()
self$userData <- new.env(parent=emptyenv())
# create output
out <- .createOutputWriter(self)
class(out) <- "shinyoutput"
@@ -201,7 +204,37 @@ MockShinySession <- R6Class(
}
},
registerDataObj = function(name, data, filterFunc) {}
registerDataObj = function(name, data, filterFunc) {},
allowReconnect = function(value) {},
reload = function() {},
resetBrush = function(brushId) {
warning("session$brush isn't meaningfully mocked on the MockShinySession")
},
sendCustomMessage = function(type, message) {},
sendBinaryMessage = function(type, message) {},
sendInputMessage = function(inputId, message) {},
setBookmarkExclude = function(names) {
warning("Bookmarking isn't meaningfully mocked in MockShinySession")
},
getBookmarkExclude = function() {
warning("Bookmarking isn't meaningfully mocked in MockShinySession")
},
onBookmark = function(fun) {
warning("Bookmarking isn't meaningfully mocked in MockShinySession")
},
onBookmarked = function(fun) {
warning("Bookmarking isn't meaningfully mocked in MockShinySession")
},
doBookmark = function() {
warning("Bookmarking isn't meaningfully mocked in MockShinySession")
},
onRestore = function(fun) {},
onRestored = function(fun) {},
exportTestValues = function() {},
getTestSnapshotUrl = function(input=TRUE, output=TRUE, export=TRUE, format="json") {},
ns = function(id) {
paste0("mock-session-", id) # TODO: does this need to be more complex/intelligent?
}
),
private = list(
.input = NULL,
@@ -231,6 +264,13 @@ MockShinySession <- R6Class(
# here since flush is private.
private$returnedVal <- value
private$flush()
},
request = function(value) {
if (!missing(value)){
stop("session$request can't be assigned to")
}
warning("session$request doesn't currently simulate a realistic request on MockShinySession")
new.env(parent=emptyenv())
}
)
)