Checkpoint initial implementation
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
from pytest import fixture
|
||||
from tungston.core.ecology.biomefilter import BiomeFilter
|
||||
from tungston.core.habitat import Habitat
|
||||
|
||||
import tungston.core.ecology.flora as FL
|
||||
import tungston.core.ecology.heat as HE
|
||||
import tungston.core.season as SE
|
||||
import tungston.core.scarcity as SC
|
||||
|
||||
|
||||
# Fixtures #########################################################################################
|
||||
|
||||
@fixture(name="fields")
|
||||
def createFieldsFilter():
|
||||
yield BiomeFilter([FL.FIELD, HE.TEMPERATE])
|
||||
|
||||
@fixture(name="derivedHabitats")
|
||||
def createDerivedHabitat(fields):
|
||||
yield (
|
||||
Habitat(biomeFilter=fields, seasons=SE.SUMMER, scarcity=SC.COMMON)
|
||||
.derive(seasons=SE.AUTUMN, scarcity=SC.UNCOMMON)
|
||||
.derive(seasons=SE.WINTER, scarcity=SC.ABSENT)
|
||||
.collect()
|
||||
)
|
||||
|
||||
@fixture(name="fields")
|
||||
def createFieldsHabitat(fields):
|
||||
yield Habitat(biomeFilter=fields)
|
||||
|
||||
# Tests ############################################################################################
|
||||
|
||||
def test_derive(derivedHabitats):
|
||||
assert [h.scarcity for h in derivedHabitats] == [SC.COMMON, SC.UNCOMMON, SC.ABSENT]
|
||||
|
||||
def test_repr(fields):
|
||||
assert repr(fields) == (
|
||||
"Habitat{" +
|
||||
"altitude: [anywhere <-64 to 320>], " +
|
||||
"biomeFilter: BiomeFilter([[Flora<field>, Heat<temperate>]], [[]]), " +
|
||||
"seasons: [Season<spring>, Season<summer>, Season<autumn>, Season<winter>], " +
|
||||
"group: solo<1 to 1>, " +
|
||||
"location: Location<outside>, " +
|
||||
"scarcity: Scarcity<sparse>" +
|
||||
"}"
|
||||
)
|
||||
Reference in New Issue
Block a user