35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""음력↔양력 변환 테스트 (sxtwl 기반)."""
|
|
from app.calculator import lunar
|
|
|
|
|
|
def test_solar_to_lunar_known_date():
|
|
# 2024년 추석 = 양력 2024-09-17 = 음력 2024-08-15
|
|
result = lunar.solar_to_lunar(2024, 9, 17)
|
|
assert result["year"] == 2024
|
|
assert result["month"] == 8
|
|
assert result["day"] == 15
|
|
assert result["is_leap"] is False
|
|
|
|
|
|
def test_lunar_to_solar_known_date():
|
|
# 음력 2024-08-15 → 양력 2024-09-17
|
|
result = lunar.lunar_to_solar(2024, 8, 15, is_leap=False)
|
|
assert result == (2024, 9, 17)
|
|
|
|
|
|
def test_solar_to_lunar_new_years():
|
|
# 양력 2024-01-01 → 음력 2023-11-20 (음력 새해는 보통 1~2월)
|
|
result = lunar.solar_to_lunar(2024, 1, 1)
|
|
assert result["year"] in (2023, 2024)
|
|
assert result["month"] in range(1, 13)
|
|
|
|
|
|
def test_roundtrip():
|
|
# 양력 → 음력 → 양력 = 원본
|
|
solar_input = (1990, 5, 15)
|
|
lunar_mid = lunar.solar_to_lunar(*solar_input)
|
|
solar_back = lunar.lunar_to_solar(
|
|
lunar_mid["year"], lunar_mid["month"], lunar_mid["day"], lunar_mid["is_leap"]
|
|
)
|
|
assert solar_back == solar_input
|