summaryrefslogtreecommitdiff
path: root/tests/test-calendar-sync--parse-recurrence-id.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-02-03 07:39:50 -0600
committerCraig Jennings <c@cjennings.net>2026-02-03 07:39:50 -0600
commit84a02097bf842e96f7f4dd4e4ac39e78faf64989 (patch)
treea3a87b6b3d75ae4179924a62c318b05fa0bd0751 /tests/test-calendar-sync--parse-recurrence-id.el
parent089a4313660cb8af1eca3829ffbdbae70f72333a (diff)
feat(calendar-sync): add RECURRENCE-ID exception handling for recurring events
Handle rescheduled instances of recurring calendar events by processing RECURRENCE-ID properties from ICS files. When someone reschedules a single instance of a recurring meeting in Google Calendar, the calendar-sync module now shows the rescheduled time instead of the original RRULE time. New functions: - calendar-sync--get-recurrence-id: Extract RECURRENCE-ID from event - calendar-sync--get-recurrence-id-line: Get full line with TZID params - calendar-sync--parse-recurrence-id: Parse into (year month day hour minute) - calendar-sync--collect-recurrence-exceptions: Collect all exceptions by UID - calendar-sync--occurrence-matches-exception-p: Match occurrences to exceptions - calendar-sync--apply-single-exception: Apply exception data to occurrence - calendar-sync--apply-recurrence-exceptions: Apply all exceptions to occurrences Also adds DeepSat calendar configuration (dcal-file) to user-constants, init.el, and org-agenda-config. 48 unit and integration tests added covering normal, boundary, and error cases.
Diffstat (limited to 'tests/test-calendar-sync--parse-recurrence-id.el')
-rw-r--r--tests/test-calendar-sync--parse-recurrence-id.el99
1 files changed, 99 insertions, 0 deletions
diff --git a/tests/test-calendar-sync--parse-recurrence-id.el b/tests/test-calendar-sync--parse-recurrence-id.el
new file mode 100644
index 00000000..6bc67344
--- /dev/null
+++ b/tests/test-calendar-sync--parse-recurrence-id.el
@@ -0,0 +1,99 @@
+;;; test-calendar-sync--parse-recurrence-id.el --- Tests for RECURRENCE-ID parsing -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Unit tests for calendar-sync--parse-recurrence-id function.
+;; Tests parsing RECURRENCE-ID values into (year month day hour minute) lists.
+;; Following quality-engineer.org guidelines: one function per file.
+
+;;; Code:
+
+(require 'ert)
+(add-to-list 'load-path (expand-file-name "." (file-name-directory load-file-name)))
+(add-to-list 'load-path (expand-file-name "../modules" (file-name-directory load-file-name)))
+(require 'testutil-calendar-sync)
+(require 'calendar-sync)
+
+;;; Normal Cases
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-normal-simple-datetime-returns-list ()
+ "Test parsing simple RECURRENCE-ID datetime without suffix."
+ (let ((result (calendar-sync--parse-recurrence-id "20260203T090000")))
+ (should (equal '(2026 2 3 9 0) result))))
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-normal-with-z-suffix-returns-list ()
+ "Test parsing RECURRENCE-ID datetime with UTC Z suffix."
+ (let ((result (calendar-sync--parse-recurrence-id "20260203T170000Z")))
+ (should (equal '(2026 2 3 17 0) result))))
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-normal-date-only-returns-list ()
+ "Test parsing date-only RECURRENCE-ID for all-day events.
+Returns list with nil for hour/minute."
+ (let ((result (calendar-sync--parse-recurrence-id "20260203")))
+ (should (equal '(2026 2 3 nil nil) result))))
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-normal-with-seconds-returns-list ()
+ "Test parsing datetime with non-zero seconds (seconds ignored)."
+ (let ((result (calendar-sync--parse-recurrence-id "20260203T091530")))
+ (should (equal '(2026 2 3 9 15) result))))
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-normal-afternoon-time-returns-list ()
+ "Test parsing afternoon time correctly."
+ (let ((result (calendar-sync--parse-recurrence-id "20260515T143000")))
+ (should (equal '(2026 5 15 14 30) result))))
+
+;;; Boundary Cases
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-boundary-midnight-returns-list ()
+ "Test parsing midnight time."
+ (let ((result (calendar-sync--parse-recurrence-id "20260203T000000")))
+ (should (equal '(2026 2 3 0 0) result))))
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-boundary-end-of-day-returns-list ()
+ "Test parsing end-of-day time (23:59)."
+ (let ((result (calendar-sync--parse-recurrence-id "20260203T235900")))
+ (should (equal '(2026 2 3 23 59) result))))
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-boundary-leap-year-returns-list ()
+ "Test parsing leap year date (Feb 29)."
+ (let ((result (calendar-sync--parse-recurrence-id "20280229T120000")))
+ (should (equal '(2028 2 29 12 0) result))))
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-boundary-new-years-eve-returns-list ()
+ "Test parsing New Year's Eve date."
+ (let ((result (calendar-sync--parse-recurrence-id "20261231T235900")))
+ (should (equal '(2026 12 31 23 59) result))))
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-boundary-january-first-returns-list ()
+ "Test parsing January 1st."
+ (let ((result (calendar-sync--parse-recurrence-id "20260101T000000")))
+ (should (equal '(2026 1 1 0 0) result))))
+
+;;; Error Cases
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-error-empty-string-returns-nil ()
+ "Test that empty string returns nil."
+ (should (null (calendar-sync--parse-recurrence-id ""))))
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-error-nil-input-returns-nil ()
+ "Test that nil input returns nil."
+ (should (null (calendar-sync--parse-recurrence-id nil))))
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-error-invalid-format-returns-nil ()
+ "Test that invalid format returns nil."
+ (should (null (calendar-sync--parse-recurrence-id "not-a-date"))))
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-error-incomplete-date-returns-nil ()
+ "Test that incomplete date returns nil."
+ (should (null (calendar-sync--parse-recurrence-id "2026"))))
+
+(ert-deftest test-calendar-sync--parse-recurrence-id-error-partial-datetime-returns-nil ()
+ "Test that partial datetime (missing time) still parses as date-only."
+ ;; A date without time component should parse as date-only
+ (let ((result (calendar-sync--parse-recurrence-id "20260203T")))
+ ;; Could return nil or partial - implementation decides
+ ;; But shouldn't crash
+ (should (or (null result)
+ (and (listp result) (= (length result) 5))))))
+
+(provide 'test-calendar-sync--parse-recurrence-id)
+;;; test-calendar-sync--parse-recurrence-id.el ends here