### Persephone - a socio-economic-ecological model of European agricultural landscapes. ### ### These are the tests for the nature model (excluding individual species). ### @testset "Species macros" begin #TODO end @testset "Habitat macros" begin #TODO end @testset "Species initialisation" begin model = smalltestlandscape() specname = "test_animal" species = Dict("name"=>specname) # create a set of initialisation functions initfun1 = Ps.initrandompopulation(10) initfun2 = Ps.initrandompopulation(6*6*3, asexual=true) initfun3 = Ps.initpopulation(@habitat(Ps.@landcover() == Ps.grass), pairs=true) initfun4 = Ps.initpopulation(@habitat(Ps.@landcover() == Ps.water && Ps.@countanimals(specname, 0) <= 5), popsize=10) # apply and test the initialisation functions @test_logs (:info, "Initialised 10 $(specname)s.") initfun1(species, model) @test all(a -> a.sex in (Ps.male, Ps.female), allagents(model)) genocide!(model) @test_logs (:info, "Initialised 108 $(specname)s.") initfun2(species, model) @test countanimals((1,1), model, specname, 0) == countanimals((6,6), model, specname, 0) == 3 @test Vector(nearby_animals((1,1), model, 0))[1].sex == Ps.hermaphrodite genocide!(model) @test_logs (:info, "Initialised 16 $(specname)s.") initfun3(species, model) @test countanimals((2,2), model, specname, 2) == countanimals((5,3), model, specname, 1) == 0 @test countanimals((5,5), model, specname, 0) == countanimals((6,6), model, specname, 0) == 2 a1, a2 = Vector(nearby_animals((6,6), model, 0)) @test a1.sex != a2.sex genocide!(model) @test_logs((:warn, "There are not enough suitable locations for $(specname) in the landscape."), (:info, "Initialised 5 $(specname)s."), initfun4(species, model)) @test countanimals((1,1), model, specname, 4) == 0 @test countanimals((6,4), model, specname, 0) == 5 end @testset "Population functions" begin #TODO end