Error in `installPackage(session = mySsim, name = "stsimsf")`: unused argument (name = "stsimsf")

# Copyright (c) 2024 Apex Resource Management Solution Ltd. (ApexRMS). All rights reserved.
# MIT License ## lines 41, 175, 226 fail in test env.
installPackage(session = mySsim, name = "stsimsf")
installPackage(session = mySsim, name = "helloworld")
test_that("Tests of Session - assumes SyncroSim is installed", {
expect_equal(file.exists(filepath(mySsim)), TRUE) # Lists the folder location of SyncroSim session
expect_output(str(version(mySsim)), "chr", fixed = TRUE) # Lists the version of SyncroSim session
expect_equal(names(package(mySsim)), c("name", "description", "version", "location", "status")) # Dataframe of the modules installed with this verions of SyncroSim.
mySession <- session(silent = FALSE) # modify default session settings
test_that("Tests of command  - assumes SyncroSim is installed", {
expect_equal(command("help", mySsim)[1], "SyncroSim System Console")
expect_equal(command(c("list", "help"), mySsim)[1], "Lists existing items")
expect_equal(command("--create --help", mySsim)[1], "Creates an item")
expect_equal(command(list(create = NULL, help = NULL), mySsim)[1], "Creates an item")
expect_error({delete(paste0(getwd(), "/temp.ssim"), force = TRUE)},
args <- list(create = NULL, library = NULL, name = paste0(getwd(), "/temp.ssim"), package = "nonexistentpackage")
expect_equal(output[1], "The specified package is not installed.")
test_that("Tests of Library - assumes SyncroSim is installed", {
myLibrary <- ssimLibrary(name = "temp", session = mySsim) # create new library using default model
expect_equal(delete(myLibrary, force = TRUE), TRUE)
myLibrary <- ssimLibrary(name = "SSimLibrary", session = mySsim)
# Get/set the various properties of the library
# Changed from NA to FALSE to match updated behaviors
expect_equal(names(ssimLibrary(myLibrary, session = mySsim)), c("property", "value"))
expect_equal(class(ssimLibrary(myLibrary, summary = FALSE, mySsim))[1], "SsimLibrary")
description(myLibrary) <- "A new description.\nTry a linebreak." # NOTE: \n adds a linebreak to the description
test_that("Tests of projects and scenarios - assumes SyncroSim is installed", {
myLib <- ssimLibrary(name = "temp26", session = mySsim, overwrite = TRUE)
myOtherLib <- ssimLibrary(name = "temp27", session = mySsim, overwrite = TRUE)
myOtherLibProj <- project(ssimObject = myOtherLib, project = "MyProj")
myOtherScn <- scenario(myOtherLibProj, scenario = "other")
ret <- delete(myOtherLib, scenario = "other", force = TRUE)
myOtherScn <- scenario(myOtherLib, scenario = "other2")
myProject <- project(myLib, project = "temp")
expect_equal(names(datasheet(myProject)), c("scope", "name", "displayName")) # Only scope, name and displayName returned
summary="CORE")$name), TRUE) # same thing, but more system calls. Generally using ids/objects is faster than using names.
expect_equal(names(datasheet(myProject, optional = TRUE)), c("scope", "package", "name", "displayName", "isSingle", "isOutput", "displayMember"))
expect_error(scenario(myLib, scenario = 1), "Scenario ids (1) not found in ssimObject. To make new scenarios, please provide names (as one or more character strings) to the scenario argument of the scenario() function. SyncroSim will automatically assign scenario ids.", fixed = TRUE) # Fail: need a name to create a scenario
myScn <- scenario(myLib, scenario = "one") # Ok because only one project in the library.
myProject <- project(myLib, project = "temp2")
myScn <- scenario(myLib, scenario = "one") # Ok because only one scenario of this name occurs in the library.
myScn <- scenario(myProject, scenario = "one") # Creates a new scenario called "one" in the second project.
expect_error(scenario(myLib, scenario = "one"), "The ssimObject contains more than one scenario called one. Specify a scenario id: 1,2", fixed = TRUE) # Fails because now there are two scenarios called "one" in the library.
myScn <- scenario(myProject, scenario = "one", overwrite = TRUE) # Overwrites existing scenario, assigns new id.
myScn <- scenario(myProject, scenario = "two", overwrite = TRUE, sourceScenario = 1) # Can copy scenarios between projects.
myScn <- scenario(myProject, scenario = "other", overwrite = TRUE, sourceScenario = myOtherScn) # Can copy scenarios between libraries if sourceScenario is a scenario object.
myOtherProject <- project(myOtherLib, project = "copy", sourceProject = myProject) # Can copy projects among libraries provided that sourceProject is a Project object.
# TODO This fails for an unknown reason => BUG SUBMITED
myOtherProject <- project(myLib, project = "copy", sourceProject = 11) # Copy a project within the same library.
expect_warning(project(myLib, project = "temp", sourceProject = "temp2"), "Project  (1) already exists, so sourceProject argument was ignored.", fixed = TRUE) # Warns that sourceProject is ignored because "temp" already exists.
myOtherProject <- project(myLib, project = "copy2", sourceProject = "temp2") # Copy a project by name
expect_equal(project(myLib)$name, c("copy", "copy2", "temp", "temp2"))
ret <- delete(myProject, scenario = "one", force = TRUE)
myScn <- scenario(myProject, scenario = "one", sourceScenario = "one") # Ok because only one possible source
expect_warning(scenario(myProject, scenario = "one", sourceScenario = "one"), "ourceScenario was ignored because scenario already exists.", fixed = TRUE) # Warns that sourceScenario will be ignored.
expect_error(scenario(myProject, scenario = "three", sourceScenario = "one"), "There is more than one scenario called one in the SsimLibrary. Please provide a sourceScenario id: 1,6", fixed = TRUE) # Fail if more than one scenario named sourceScenario in the library.
expect_equal(nrow(scenario(myScn, summary = TRUE)), 1) # return summary info
expect_is(datasheet(myScn, "core_SysFolder"), "data.frame") # returns a datasheet
expect_is(datasheet(myScn, "core_SysFolder", forceElements = TRUE), "list") # returns a list
expect_equal(length(datasheet(myScn, c("core_Settings", "core_SysFolder"))), 2) # returns a list
allScns <- scenario(myProject, summary = FALSE)
expect_equal(is.element("ScenarioId", names(datasheet(myLib, c("RunControl", "OutputOptions"), scenario = as.numeric(names(allScns)))[[1]])), TRUE) # returns a list - each sheet contains scenario info if appropriate
expect_equal(length(datasheet(allScns, c("RunControl", "OutputOptions"))), 2) # returns a list - each sheet contains scenario info if appropriate
expect_warning(datasheet(myScn, "RunControl", scenario = 1), "scenario argument is ignored when ssimObject is a Scenario or list of these.", fixed = TRUE) # Warn of conflict between ssimObject and scenario arguments.
expect_warning(datasheet(myProject, "corestime_Charts", project = 1), "project argument is ignored when ssimObject is a Project/Scenario or list of these.", fixed = TRUE) # Warn of conflict between ssimObject and project arguments.
expect_warning(datasheet(allScns, "RunControl", scenario = 1), "scenario argument is ignored when ssimObject is a list.", fixed = TRUE) # Warn that project/scenario arguments are ignored when ssimObject is a list of Project/Scenario objects.
expect_equal(runLog(myScn), "The scenario is not a result scenario: 6") # Returns message if the scenario is not a result scenario.
description(myProject) <- "A new description.\nTry a linebreak." # NOTE: \n adds a linebreak to the description
expect_equal(parentId(myScn), NA) # NA for scenarios that aren't results.
expect_is(ssimLibrary(myProject), "SsimLibrary") # get parent library
expect_is(session(myProject), "Session") # get parent session
expect_is(ssimLibrary(myScn), "SsimLibrary") # get parent library
expect_is(session(myScn), "Session") # get parent session
expect_equal(projectId(project(myScn)), projectId(myScn)) # get parent project
ret <- scenario(myProject, scenario = "another scn")
targetScn <- scenario(myProject, scenario = "second scen")
ret <- dependency(targetScn, dependency = c("other", "New scn name", "another scn")) # elements of the dependency argument are ordered from lowest to highest precedence
expect_equal(dependency(targetScn)$name, c("another scn", "New scn name", "other"))
ret <- dependency(targetScn, dependency = c("another scn", "New scn name")) # change the precedence of dependencies by adding them again.
expect_equal(dependency(targetScn)$name, c("New scn name", "another scn", "other")) # now "New scn name" has highest precedence.
# test delete - vectors of project/scenario/datasheet
retList <- delete(myLib, project = project(myLib)$projectId[1:2],
datasheet = c("corestime_Charts", "corestime_DistributionType"), force = TRUE)
ret <- delete(myLib, scenario = c(6, 7), force = TRUE)
ret <- delete(myLib, scenario = c("one", "two"), force = TRUE)
ret <- delete(myLib, project = c(1, 11), force = TRUE)
ret <- delete(myLib, project = c("copy", "copy2"), force = TRUE)
ret <- delete(paste0(getwd(), "/temp27.ssim"), force = TRUE) # delete a library specified by a path
expect_error({delete(paste0(getwd(), "/temp26.ssim"), force = TRUE)},
test_that("Tests of datasheet - assumes SyncroSim is installed", {
myLibrary <- ssimLibrary(name = "NewLibrary.ssim", session = mySsim)
myProject <- project(myLibrary, project = "proj")
myScenario <- scenario(myProject, scenario = "one")
myLibraryDataframes <- datasheet(myLibrary, summary = FALSE) # A named list of all the library datasheets for project id 2.
myProjectSheetNames <- subset(datasheet(myProject), scope == "project") # A dataframe of datasheet names for project id 1.
myDeterministicTransitions <- suppressWarnings(datasheet(myScenario, "DeterministicTransition", lookupsAsFactors = FALSE)) # This option returns characters instead of factors.
emptyTab <- datasheet(myProject, name = sheetName, empty = FALSE)
stateClassDefinition <- addRow(emptyTab, data.frame(Name = c("Coniferous", "Deciduous", "Mixed")))
ret <- saveDatasheet(myProject, stateClassDefinition, name = sheetName) # append project scope datasheet by default
ret <- saveDatasheet(myProject, stateClassDefinition, name = sheetName, append = FALSE, force = TRUE) # remove without prompting
stateClassDefinition <- addRow(emptyTab, data.frame(Name = c("Grass")))
expect_equal(datasheet(myProject, name = sheetName)$Name, c("Coniferous", "Deciduous", "Grass", "Mixed"))
ret <- delete(myProject, datasheet = sheetName, force = TRUE)
expect_equal(nrow(datasheet(myProject, name = sheetName)), 0)