37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
|
|
"""Compatibility tests for the production calendar contract."""
|
||
|
|
|
||
|
|
from datetime import date
|
||
|
|
|
||
|
|
from app.labor_calendar_logic import format_day_context
|
||
|
|
from app.merakomis_schema import DAY_TYPE_NO_WORK
|
||
|
|
|
||
|
|
|
||
|
|
def test_calendar_contract_for_normal_weekday():
|
||
|
|
value = format_day_context(None, date(2026, 9, 14))
|
||
|
|
|
||
|
|
assert value["normal_hours"] == 8.0
|
||
|
|
assert value["is_non_working"] is False
|
||
|
|
assert value["source_explanation"] == "Рабочий день"
|
||
|
|
|
||
|
|
|
||
|
|
def test_calendar_contract_for_shortened_day_uses_source_text():
|
||
|
|
value = format_day_context(
|
||
|
|
{"hours": 7, "text": "Предпраздничный день", "type": 0},
|
||
|
|
date(2026, 12, 31),
|
||
|
|
)
|
||
|
|
|
||
|
|
assert value["normal_hours"] == 7.0
|
||
|
|
assert value["is_non_working"] is False
|
||
|
|
assert value["source_explanation"] == "Предпраздничный день"
|
||
|
|
|
||
|
|
|
||
|
|
def test_calendar_contract_for_official_non_working_day_has_zero_norm():
|
||
|
|
value = format_day_context(
|
||
|
|
{"hours": 8, "text": "Праздник", "type": DAY_TYPE_NO_WORK},
|
||
|
|
date(2026, 11, 4),
|
||
|
|
)
|
||
|
|
|
||
|
|
assert value["normal_hours"] == 0.0
|
||
|
|
assert value["is_non_working"] is True
|
||
|
|
assert value["source_explanation"] == "Праздник"
|