[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Testing: Add tests for 'org-agenda-check-for-timestamp-as-reason
From: |
Morgan Smith |
Subject: |
[PATCH] Testing: Add tests for 'org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item' |
Date: |
Mon, 17 Jul 2023 11:37:44 -0400 |
* testing/lisp/test-org-agenda.el
(test-org-agenda/check-for-timestamp-as-reason-to-ignore-todo-item):
New test.
---
testing/lisp/test-org-agenda.el | 56 +++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el
index c4bd4f0a7..66f2f5bce 100644
--- a/testing/lisp/test-org-agenda.el
+++ b/testing/lisp/test-org-agenda.el
@@ -329,6 +329,62 @@ DEADLINE: <2023-07-15 Sat>"
"* TODO write better tests"
(org-agenda-skip-if nil options))))))
+(ert-deftest test-org-agenda/check-for-timestamp-as-reason-to-ignore-todo-item
()
+ "Test `org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item'."
+ (let ((org-deadline-warning-days 1)
+ (expected-return
+ (lambda (timestamp value)
+ (cl-case timestamp
+ (past (not (not (memq value '(past all -1 -2 near)))))
+ (yesteryesterday (not (not (memq value '(past all -1 -2 near)))))
+ (yesterday (not (not (memq value '(past all -1 near)))))
+ (today (not (not (memq value '(all past 0 near)))))
+ (tomorrow (not (not (memq value '(future all 1 0 near)))))
+ (tomorroworrow (not (not (memq value '(future all 2 1 0 far)))))
+ (future (not (not (memq value '(future all 2 1 0 far))))))))
+ ;; Lexically bind the variables we're changing
+ org-agenda-todo-ignore-deadlines
+ org-agenda-todo-ignore-scheduled
+ org-agenda-todo-ignore-timestamp)
+ (org-test-at-time "2023-01-15"
+ (dolist (variable '(org-agenda-todo-ignore-deadlines
+ org-agenda-todo-ignore-scheduled
+ org-agenda-todo-ignore-timestamp))
+ (dolist (type '(timestamp scheduled deadline))
+ ;; nil is last so it resets the variable for the next one
+ (dolist (value `(past future all 2 1 0 -1 -2
+ ,@(when (eq type 'deadline) '(near far
nil))))
+ (dolist (timestamp '((past . "<2022-01-15>")
+ (yesteryesterday . "<2023-01-13>")
+ (yesterday . "<2023-01-14>")
+ (today . "<2023-01-15>")
+ (tomorrow . "<2023-01-16>")
+ (tomorroworrow . "<2023-01-17>")
+ (future . "<2024-01-15>")))
+ ;; Uncomment to debug failure
+ ;; (message "Type: %S, Variable: %S, Value: %S, Time: %S" type
variable value (car timestamp))
+ (set variable value)
+ (should
+ (equal
+ (cl-case variable
+ (org-agenda-todo-ignore-deadlines
+ (when (eq type 'deadline)
+ (funcall expected-return (car timestamp) value)))
+ (org-agenda-todo-ignore-scheduled
+ (when (eq type 'scheduled)
+ (funcall expected-return (car timestamp) value)))
+ (org-agenda-todo-ignore-timestamp
+ (when (eq type 'timestamp)
+ (funcall expected-return (car timestamp) value))))
+ (org-test-with-temp-text
+ (cl-case type
+ (timestamp (concat "* hello " (cdr timestamp)))
+ (scheduled (concat "* hello
+SCHEDULED: " (cdr timestamp)))
+ (deadline (concat "* hello
+DEADLINE: " (cdr timestamp))))
+
(org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item)))))))))))
+
(ert-deftest test-org-agenda/goto-date ()
"Test `org-agenda-goto-date'."
(unwind-protect
--
2.41.0
- [PATCH] Testing: Add tests for 'org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item',
Morgan Smith <=