diff --git a/test/landscape_tests.jl b/test/landscape_tests.jl index a500e526b5b3758a05639ecb0daba703d8e6d8e7..7f1fe4266a15ca6651d0057510a0cf2229336c32 100644 --- a/test/landscape_tests.jl +++ b/test/landscape_tests.jl @@ -64,7 +64,7 @@ end @test Ps.distancetoedge((6,6), model) == 20m end -@testset "Weather initialisation" begin +@testset "Weather interface" begin # these tests are specific to the Jena weather file model = inittestmodel() @test length(model.weather) == 59 diff --git a/test/runtests.jl b/test/runtests.jl index f30aca6495bf1d9c79367aa4b7b68143a6f80a59..a655c01849151bd01c0fdffea176676d1c11ac1e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -92,6 +92,9 @@ end include("landscape_tests.jl") include("simulation_tests.jl") end + @testset "Weather model" begin + include("weather_tests.jl") + end @testset "Nature model" begin include("nature_tests.jl") end diff --git a/test/weather_tests.jl b/test/weather_tests.jl new file mode 100644 index 0000000000000000000000000000000000000000..4f838c58b040b292f925f78d33fbd96e48f3bc85 --- /dev/null +++ b/test/weather_tests.jl @@ -0,0 +1,27 @@ + +@testset "Constructor and interface" begin + float3 = [0.0, 1.0, 2.0] + missing3 = Union{Missing,Float64}[missing, missing, missing] + weather = Weather(; firstdate = Date("2000-01-01"), + lastdate = Date("2000-01-03"), + windspeed = missing3, + precipitation = float3, + sunshine = missing3, + cloudcover = missing3, + humidity = missing3, + meantemp = float3, + maxtemp = float3, + mintemp = float3, + evapotranspiration = float3) + date = Date("2000-01-02") + @test length(weather) == 3 + @test Ps.daynumber(weather, date) == 2 + @test Ps.windspeed(weather, date) |> ismissing + @test Ps.precipitation(weather, date) == 1.0 + @test Ps.sunshine(weather, date) |> ismissing + @test Ps.humidity(weather, date) |> ismissing + @test Ps.meantemp(weather, date) == 1.0 + @test Ps.maxtemp(weather, date) == 1.0 + @test Ps.mintemp(weather, date) == 1.0 + @test Ps.evapotranspiration(weather, date) == 1.0 +end