34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import tempfile
|
|
import unittest
|
|
from datetime import date
|
|
from pathlib import Path
|
|
|
|
from daily_report.workday import is_workday
|
|
|
|
|
|
class WorkdayTest(unittest.TestCase):
|
|
def test_uses_holidays_and_makeup_workdays(self) -> None:
|
|
with tempfile.TemporaryDirectory(prefix="daily-report-workday-") as temp:
|
|
calendar_path = Path(temp) / "calendar.json"
|
|
calendar_path.write_text(
|
|
json.dumps(
|
|
{
|
|
"holidays": ["2026-05-01"],
|
|
"makeup_workdays": ["2026-05-09"],
|
|
}
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
|
|
self.assertFalse(is_workday(date(2026, 5, 1), calendar_path))
|
|
self.assertTrue(is_workday(date(2026, 5, 9), calendar_path))
|
|
self.assertFalse(is_workday(date(2026, 5, 10), calendar_path))
|
|
self.assertTrue(is_workday(date(2026, 5, 11), calendar_path))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|