Something went wrong on our end
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
io_tests.jl 1.45 KiB
### Persephone - a socio-economic-ecological model of European agricultural landscapes.
###
### This tests the core input and output functions.
###
@testset "Model configuration" begin
# `test_parameters.toml` is read in in `runtests.jl`
@test param("core.configfile") == TESTPARAMETERS
@test param("core.startdate") == Date(2020, 1, 1)
@test param("nature.targetspecies") == ["Wolpertinger", "Wyvern"]
#TODO test commandline parameters
end
@testset "Output functions" begin
# test that the output directory is created with all files
logstring = "Setting up output directory results_testsuite_$(Dates.today())_s1"
@test_logs (:info, logstring) Persephone.setupdatadir()
@test isdir(param("core.outdir"))
@test isfile(joinpath(param("core.outdir"), param("core.landcovermap")))
@test isfile(joinpath(param("core.outdir"), param("core.farmfieldsmap")))
@test isfile(joinpath(param("core.outdir"), param("core.configfile")))
@test isfile(joinpath(param("core.outdir"), Persephone.LOGFILE))
# check whether the overwrite warning/protection works
logstring = "Overwriting existing output directory $(param("core.outdir"))."
@test_logs (:warn, logstring) match_mode=:any Persephone.setupdatadir()
#TODO test overwrite protection (requires parameter mutability)
rm(param("core.outdir"), force=true, recursive=true)
#TODO test that creating a DataOutput works, and outputs data with the required frequency
end