| 123456789101112131415161718192021222324252627282930313233343536373839 |
- from datetime import date
- from app.services.oa_resignation_kit_sync import extract_last_work_day
- def test_extract_last_work_day():
- schema = {
- "rule": [
- {
- "type": "resignationKit",
- "props": {"lastWorkDayField": "f_last"},
- "children": [
- {
- "type": "datePicker",
- "field": "f_last",
- "props": {"_fc_kit_field": "lastWorkDay"},
- }
- ],
- }
- ]
- }
- assert extract_last_work_day(schema, {"f_last": "2026-08-01"}) == date(2026, 8, 1)
- def test_empty_skipped():
- schema = {
- "rule": [
- {
- "type": "resignationKit",
- "props": {"lastWorkDayField": "f_last"},
- "children": [],
- }
- ]
- }
- assert extract_last_work_day(schema, {"f_last": ""}) is None
- def test_no_kit():
- assert extract_last_work_day({"rule": [{"type": "input", "field": "x"}]}, {"x": 1}) is None
|