tests/testthat/test-groupByDistrict.R

context("Function .groupByDistrict")


sapply(studyPathS, function(studyPath){

opts <- setSimulationPath(studyPath)
  
describe(".groupByDistrict", {

  it("groups data by district", {
    mydata <- readAntares(c("a", "b"), select = "LOAD", timeStep = "monthly", showProgress = FALSE)
    mydataAgg <- .groupByDistrict(mydata, opts)
    expect_true(is.null(mydataAgg$area))
    expect_false(any(duplicated(mydataAgg[, .(district, timeId, time)])))

    expect_identical(mydataAgg$LOAD,
                     mydata[area=="a", LOAD] + mydata[area=="b", LOAD])
  })

  it("throws a warning if an area is missing", {
    mydata <- readAntares("a", select = "LOAD", timeStep = "monthly", showProgress = FALSE)
    expect_warning(.groupByDistrict(mydata, opts), " b$")
  })
})
})

Try the antaresRead package in your browser

Any scripts or data that you put into this service are public.

antaresRead documentation built on Sept. 13, 2024, 1:12 a.m.