test_oa_resignation_kit_sync.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from datetime import date
  2. from app.services.oa_resignation_kit_sync import extract_last_work_day
  3. def test_extract_last_work_day():
  4. schema = {
  5. "rule": [
  6. {
  7. "type": "resignationKit",
  8. "props": {"lastWorkDayField": "f_last"},
  9. "children": [
  10. {
  11. "type": "datePicker",
  12. "field": "f_last",
  13. "props": {"_fc_kit_field": "lastWorkDay"},
  14. }
  15. ],
  16. }
  17. ]
  18. }
  19. assert extract_last_work_day(schema, {"f_last": "2026-08-01"}) == date(2026, 8, 1)
  20. def test_empty_skipped():
  21. schema = {
  22. "rule": [
  23. {
  24. "type": "resignationKit",
  25. "props": {"lastWorkDayField": "f_last"},
  26. "children": [],
  27. }
  28. ]
  29. }
  30. assert extract_last_work_day(schema, {"f_last": ""}) is None
  31. def test_no_kit():
  32. assert extract_last_work_day({"rule": [{"type": "input", "field": "x"}]}, {"x": 1}) is None