Skip to content
Snippets Groups Projects
Commit 8fc84186 authored by xo30xoqa's avatar xo30xoqa
Browse files

Wrote basic I/O tests

parent 3a702e24
Branches
Tags
No related merge requests found
...@@ -3,4 +3,27 @@ ...@@ -3,4 +3,27 @@
### This tests the core input and output functions. ### This tests the core input and output functions.
### ###
#TODO @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
...@@ -9,10 +9,13 @@ Pkg.activate("..") ...@@ -9,10 +9,13 @@ Pkg.activate("..")
using Persephone using Persephone
using Test using Test
using Random using Random
using Dates
using Agents using Agents
const TESTPARAMETERS = "test_parameters.toml"
@testset "Persephone Tests" begin @testset "Persephone Tests" begin
Persephone.initsettings("test_parameters.toml") Persephone.initsettings(TESTPARAMETERS)
@testset "Core model" begin @testset "Core model" begin
include("io_tests.jl") include("io_tests.jl")
include("landscape_tests.jl") include("landscape_tests.jl")
......
...@@ -8,7 +8,8 @@ configfile = "test_parameters.toml" # location of the configuration file ...@@ -8,7 +8,8 @@ configfile = "test_parameters.toml" # location of the configuration file
landcovermap = "landcover_jena.tif" # location of the landcover map landcovermap = "landcover_jena.tif" # location of the landcover map
farmfieldsmap = "fields_jena.tif" # location of the field geometry map farmfieldsmap = "fields_jena.tif" # location of the field geometry map
outdir = "results_testsuite" # location and name of the output folder outdir = "results_testsuite" # location and name of the output folder
loglevel = "debug" # verbosity level: "debug", "info", "quiet" overwrite = true # overwrite the output directory? (true/false/"ask")
loglevel = "info" # verbosity level: "debug", "info", "quiet"
seed = 1 # seed value for the RNG (0 -> random value) seed = 1 # seed value for the RNG (0 -> random value)
# dates to start and end the simulation # dates to start and end the simulation
startdate = 2020-01-01 startdate = 2020-01-01
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment