Skip to content
Snippets Groups Projects
Commit 4c5b17c2 authored by Marco Matthies's avatar Marco Matthies
Browse files

Better unit test for AquaCrop cropyield()

parent 4dda213a
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ mutable struct AquaCropState
function AquaCropState(croptype::AquaCropType, height::Length{Float64}=0.0cm)
ac_parentdir = AquaCrop.test_toml_dir # TODO: hardcoded croptype
ac_runtype = :Julia
cropstate, allok = AquaCrop.initialize_cropfield(ac_parentdir, ac_runtype)
cropstate, allok = AquaCrop.initialize_cropfield(; parentdir=ac_parentdir, runtype=ac_runtype)
if ! allok.logi
error("AquaCrop.initialize_cropfield() failed, status = $allok")
end
......
......@@ -3,17 +3,20 @@
### These are the tests for the crop growth models.
###
const TESTPARAM_ALMASS = joinpath(pkgdir(Persefone), "test", "test_parameters_almass.toml")
const TESTPARAM_SIMPLECROP = joinpath(pkgdir(Persefone), "test", "test_parameters_simplecrop.toml")
const TESTPARAM_AQUACROP = joinpath(pkgdir(Persefone), "test", "test_parameters_aquacrop.toml")
import Unitful
@testset for paramfile in (TESTPARAM_ALMASS, TESTPARAM_SIMPLECROP, TESTPARAM_AQUACROP)
@testset for paramfile in [
"test_parameters_almass.toml",
"test_parameters_simplecrop.toml",
"test_parameters_aquacrop.toml",
]
parampath = joinpath(pkgdir(Persefone), "test", paramfile)
@testset "Model initialisation" begin
model = initialise(paramfile)
model = initialise(parampath)
@test model isa AgricultureModel
end
@testset "Time step" begin
model = initialise(paramfile)
model = initialise(parampath)
stepsimulation!(model)
@test model isa AgricultureModel
end
......@@ -65,6 +68,6 @@ end
@test cropname(fp) isa String
@test cropheight(fp) isa Length{Float64}
@test cropcover(fp) isa Float64
@test cropyield(fp) isa type(1.0u"kg/ha")
@test Unitful.dimension(cropyield(fp)) == Unitful.𝐌 * Unitful.𝐋^-2
# TODO: test stepagent!(), sow!(), harvest!()
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment