87 lines
3.3 KiB
Python
87 lines
3.3 KiB
Python
"""Tests for the season system."""
|
|
|
|
from mudlib import seasons
|
|
|
|
|
|
def test_get_season_basic():
|
|
assert seasons.get_season(0) == "spring"
|
|
assert seasons.get_season(6) == "spring"
|
|
assert seasons.get_season(7) == "summer"
|
|
assert seasons.get_season(13) == "summer"
|
|
assert seasons.get_season(14) == "autumn"
|
|
assert seasons.get_season(20) == "autumn"
|
|
assert seasons.get_season(21) == "winter"
|
|
assert seasons.get_season(27) == "winter"
|
|
|
|
|
|
def test_get_season_wraps():
|
|
assert seasons.get_season(28) == "spring"
|
|
assert seasons.get_season(35) == "summer"
|
|
assert seasons.get_season(56) == "spring" # 2 years = 56 days
|
|
|
|
|
|
def test_get_season_negative_day():
|
|
assert seasons.get_season(-1) == "spring"
|
|
assert seasons.get_season(-100) == "spring"
|
|
|
|
|
|
def test_get_season_custom_days_per_season():
|
|
# 10 days per season = 40-day year
|
|
assert seasons.get_season(0, days_per_season=10) == "spring"
|
|
assert seasons.get_season(9, days_per_season=10) == "spring"
|
|
assert seasons.get_season(10, days_per_season=10) == "summer"
|
|
assert seasons.get_season(19, days_per_season=10) == "summer"
|
|
assert seasons.get_season(20, days_per_season=10) == "autumn"
|
|
assert seasons.get_season(30, days_per_season=10) == "winter"
|
|
assert seasons.get_season(40, days_per_season=10) == "spring"
|
|
|
|
|
|
def test_get_day_of_year():
|
|
assert seasons.get_day_of_year(0) == 0
|
|
assert seasons.get_day_of_year(27) == 27
|
|
assert seasons.get_day_of_year(28) == 0 # new year
|
|
assert seasons.get_day_of_year(29) == 1
|
|
assert seasons.get_day_of_year(56) == 0 # 2 years
|
|
|
|
|
|
def test_get_day_of_year_custom_days_per_season():
|
|
# 10 days per season = 40-day year
|
|
assert seasons.get_day_of_year(0, days_per_season=10) == 0
|
|
assert seasons.get_day_of_year(39, days_per_season=10) == 39
|
|
assert seasons.get_day_of_year(40, days_per_season=10) == 0
|
|
assert seasons.get_day_of_year(80, days_per_season=10) == 0
|
|
|
|
|
|
def test_get_season_description_grass():
|
|
assert "green" in seasons.get_season_description("spring", "grass")
|
|
assert "golden" in seasons.get_season_description("summer", "grass")
|
|
assert "brown" in seasons.get_season_description("autumn", "grass")
|
|
assert "frost" in seasons.get_season_description("winter", "grass")
|
|
|
|
|
|
def test_get_season_description_forest():
|
|
assert "blossom" in seasons.get_season_description("spring", "forest")
|
|
assert "canopy" in seasons.get_season_description("summer", "forest")
|
|
assert "amber" in seasons.get_season_description("autumn", "forest")
|
|
assert "bare" in seasons.get_season_description("winter", "forest")
|
|
|
|
|
|
def test_get_season_description_minimal_variation():
|
|
# sand, mountain, water have minimal/no seasonal variation
|
|
assert seasons.get_season_description("spring", "sand") == ""
|
|
assert seasons.get_season_description("summer", "mountain") == ""
|
|
assert seasons.get_season_description("winter", "water") == ""
|
|
|
|
|
|
def test_get_season_description_unknown_terrain():
|
|
# unknown terrain returns empty string
|
|
assert seasons.get_season_description("spring", "lava") == ""
|
|
assert seasons.get_season_description("summer", "unknown") == ""
|
|
|
|
|
|
def test_seasons_constant():
|
|
assert seasons.SEASONS == ["spring", "summer", "autumn", "winter"]
|
|
|
|
|
|
def test_days_per_season_constant():
|
|
assert seasons.DAYS_PER_SEASON == 7
|