From: Morgan Smith <Morgan.J.Smith@outlook.com>
To: emacs-orgmode@gnu.org
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 [thread overview]
Message-ID: <DM5PR03MB316375442476EE5B60635DA6C53BA@DM5PR03MB3163.namprd03.prod.outlook.com> (raw)
* 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
next reply other threads:[~2023-07-17 15:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-17 15:37 Morgan Smith [this message]
2023-07-18 9:31 ` [PATCH] Testing: Add tests for 'org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item' Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DM5PR03MB316375442476EE5B60635DA6C53BA@DM5PR03MB3163.namprd03.prod.outlook.com \
--to=morgan.j.smith@outlook.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).