Skip to contents

Populates the supplied session variable for testing.

Usage

CTS_test_mksession(
  session,
  id = "CTS",
  id_ASM = "ASM",
  id_MB = "MB",
  full_session = TRUE
)

Arguments

session

Shiny session variable (in app) or a list (outside of app)

id

An ID string that corresponds with the ID used to call the modules UI elements

id_ASM

An ID string that corresponds with the ID used to call the ASM module

id_MB

An ID string that corresponds with the ID used to call the MB module

full_session

Boolean to indicate if the full test session should be created (default TRUE).

Value

list with the following elements

  • isgood: Boolean indicating the exit status of the function.

  • session: The value Shiny session variable (in app) or a list (outside of app) after initialization.

  • input: The value of the shiny input at the end of the session initialization.

  • state: App state.

  • rsc: The react_state components.

Examples

# \donttest{
sess_res = CTS_test_mksession(session=list(), full_session=FALSE)
#> → MB: including file
#> → MB:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → MB:   dest:   file.path("config","report.docx")
#> → MB: including file
#> → MB:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → MB:   dest:   file.path("config","report.pptx")
#> → MB: including file
#> → MB:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → MB:   dest:   file.path("config","report.yaml")
#> ! MB: User-defined model: /Users/jmh/projects/ruminate/github/ruminate/docs/reference/user_model.R not found (skipping)
#> ! MB: User-defined model: /Users/jmh/projects/ruminate/github/ruminate/docs/reference/user_model.ctl not found (skipping)
#> → MB: module checksum updated:24933f86b657b9503f22440e8c4d3cac
#> → MB: State initialized
#> ! MB: User-defined model: /Users/jmh/projects/ruminate/github/ruminate/docs/reference/user_model.R not found (skipping)
#> ! MB: User-defined model: /Users/jmh/projects/ruminate/github/ruminate/docs/reference/user_model.ctl not found (skipping)
#>  
#>  
#>  parameter labels from comments are typically ignored in non-interactive mode
#>  Need to run with the source intact to parse comments
#> → MB: model checksum updated: 567fe35aac84d6eccd4ce9fb17b00985
#> → MB: module checksum updated:c09fbcf95189690a2c471f5b66516173
#> → CTS: including file
#> → CTS:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → CTS:   dest:   file.path("config","report.docx")
#> → CTS: including file
#> → CTS:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → CTS:   dest:   file.path("config","report.pptx")
#> → CTS: including file
#> → CTS:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → CTS:   dest:   file.path("config","report.yaml")
#> → CTS: source model change detected
#> → CTS:  > covariates reset
#> → CTS: cohort checksum updated: 798bb91fae8e6500cdcf4672fd369879
#> → CTS: module checksum updated: a6d268b6a45fca0319972a594bce9674
#> → CTS: State initialized
#> → CTS: add rule success
#> → CTS: rule added
#> → CTS: cohort checksum updated: 72cd53436746338b28c478758d83ad1e
#> → CTS: module checksum updated: 22087f144958c077a22568dc1b9ee0fc
#> → CTS: CTS_simulate_element()
#> → CTS: # Setting the random seeds
#> → CTS: set.seed(86753090)
#> → CTS: rxSetSeed(86753090)
#> → CTS: 
#> → CTS: 
#> → CTS: # Fetching the system information
#> → CTS: CTS_obj_1_rx_details = fetch_rxinfo(MB_obj_1_rx)
#> → CTS: 
#> → CTS: # Defining covariates
#> → CTS: CTS_obj_1_cov = list()
#> → CTS: 
#> → CTS: # Generating the subjects
#> → CTS: CTS_obj_1_subs = mk_subjects(object = MB_obj_1_rx,
#> → CTS:   nsub   = 2,
#> → CTS:   covs   = CTS_obj_1_cov)
#> → CTS: 
#> → CTS: # Creating rules
#> → CTS: CTS_obj_1_rules = list()
#> → CTS: 
#> → CTS: CTS_obj_1_rules[["Single_Dose"]] = 
#> → CTS: list(condition = "time == 0", action = list(type = "dose", state = "central", 
#> → CTS:     values = "c(1)", times = "c(0)", durations = "c(0)"))
#> → CTS: 
#> → CTS: # rxSolve options
#> → CTS: CTS_obj_1_rxopts = list(
#> → CTS:   atol = 1e-8,
#> → CTS:   rtol = 1e-6,
#> → CTS:   sigdig = NULL)
#> → CTS: 
#> → CTS: # Output times
#> → CTS: CTS_obj_1_output_times = formods::linspace(0,100,5)
#> → CTS: 
#> → CTS: # Running simulation
#> → CTS: CTS_obj_1_simres =                                 
#> → CTS:  simulate_rules(object            = MB_obj_1_rx,
#> → CTS:                 subjects          = CTS_obj_1_subs[["subjects"]],
#> → CTS:                 eval_times        = c(0),
#> → CTS:                 output_times      = CTS_obj_1_output_times,
#> → CTS:                 time_scales       = MB_obj_1_ts,
#> → CTS:                 rules             = CTS_obj_1_rules,
#> → CTS:                 rx_options        = CTS_obj_1_rxopts)
#> → CTS: 
#> → CTS: # Collecting the simulation and event history values
#> → CTS: CTS_obj_1_sim_tc = CTS_obj_1_simres[["simall"]]
#> → CTS: CTS_obj_1_sim_ev = CTS_obj_1_simres[["ev_history"]]
#> → CTS: message: could not find function "rxSetSeed"
#> → CTS: call:    rxSetSeed
#> → CTS: call:    86753090
#> → CTS: CTS_plot_element()
#> → CTS: # Plotting timecourse
#> → CTS: CTS_obj_1_fgtc =                                 
#> → CTS:   plot_sr_tc(sro = CTS_obj_1_simres,
#> → CTS:     fncol        = 4,                       
#> → CTS:     fnrow        = 2,                       
#> → CTS:     dvcols       = "Cc",
#> → CTS:     fpage        = 1)
#> → CTS: 
#> → CTS: # Plotting events
#> → CTS: CTS_obj_1_fgev =                                 
#> → CTS:   plot_sr_ev(sro = CTS_obj_1_simres,
#> → CTS:     fncol        = 4,                       
#> → CTS:     fnrow        = 2,                       
#> → CTS:     evplot       = 1,
#> → CTS:     fpage        = 1)
#> → CTS: There was a problem with the simulation.
#> → CTS: cohort checksum updated: 316e7dc2a8bfd0ffcdc512cfa350a7b4
#> → CTS: module checksum updated: d16851beede5de6c4083da676efafbd6
# }