40 lines
1.0 KiB
Python
40 lines
1.0 KiB
Python
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
|