[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/org-edna 8c31160 59/72: Added tests for actions
From: |
Ian Dunn |
Subject: |
[elpa] scratch/org-edna 8c31160 59/72: Added tests for actions |
Date: |
Sun, 21 May 2017 21:11:28 -0400 (EDT) |
branch: scratch/org-edna
commit 8c3116030693cc236a5b87bb2d9b467db98dc5c1
Author: Ian D <address@hidden>
Commit: Ian D <address@hidden>
Added tests for actions
* org-edna.el (org-edna-prompt-for-archive): New defcustom.
(org-edna-action/archive!): Use it.
(org-edna-action/delete-property!): New action.
* org-edna-tests.el: Added tests for the remaining actions.
* org-edna-tests.org: Added some more test headings.
---
org-edna-tests.el | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
org-edna-tests.org | 8 ++++++
org-edna.el | 13 +++++++++-
3 files changed, 93 insertions(+), 1 deletion(-)
diff --git a/org-edna-tests.el b/org-edna-tests.el
index 4698e52..27110b3 100644
--- a/org-edna-tests.el
+++ b/org-edna-tests.el
@@ -27,6 +27,7 @@
(require 'org-edna)
(require 'ert)
+(require 'org-id)
(defconst org-edna-test-dir
(expand-file-name (file-name-directory (or load-file-name
buffer-file-name))))
@@ -49,6 +50,7 @@
(defconst org-edna-test-id-heading-two
"b010cbad-60dc-46ef-a164-eb155e62cbb2")
(defconst org-edna-test-id-heading-three
"97e6b0f0-40c4-464f-b760-6e5ca9744eb5")
(defconst org-edna-test-id-heading-four
"7d4d564b-18b2-445c-a0c8-b1b3fb9ad29e")
+(defconst org-edna-test-archive-heading
"d7668277-f959-43ba-8e85-8a3c76996862")
(defun org-edna-find-test-heading (id)
"Find the test heading with id ID."
@@ -366,6 +368,77 @@
(should (string-equal (org-entry-get nil "SCHEDULED")
"<2000-01-15 Sat 00:00>")))))
+(ert-deftest org-edna-action-tag ()
+ (let ((pom (org-edna-find-test-heading org-edna-test-id-heading-one)))
+ (org-with-point-at pom
+ (org-edna-action/tag! nil "tag")
+ (should (equal (org-get-tags) '("tag")))
+ (org-edna-action/tag! nil "")
+ (should-not (org-get-tags)))))
+
+(ert-deftest org-edna-action-property ()
+ (let ((pom (org-edna-find-test-heading org-edna-test-id-heading-one)))
+ (org-with-point-at pom
+ (org-edna-action/set-property! nil "TEST" "1")
+ (should (equal (org-entry-get nil "TEST") "1"))
+ (org-edna-action/delete-property! nil "TEST")
+ (should-not (org-entry-get nil "TEST")))))
+
+(ert-deftest org-edna-action-clock ()
+ (let ((pom (org-edna-find-test-heading org-edna-test-id-heading-one)))
+ (org-with-point-at pom
+ (org-edna-action/clock-in! nil)
+ (should (org-clocking-p))
+ (should (equal org-clock-hd-marker pom))
+ (org-edna-action/clock-out! nil)
+ (should-not (org-clocking-p)))))
+
+(ert-deftest org-edna-action-priority ()
+ (let ((pom (org-edna-find-test-heading org-edna-test-id-heading-one))
+ (org-lowest-priority ?C)
+ (org-highest-priority ?A)
+ (org-default-priority ?B))
+ (org-with-point-at pom
+ (org-edna-action/set-priority! nil "A")
+ (should (equal (org-entry-get nil "PRIORITY") "A"))
+ (org-edna-action/set-priority! nil 'down)
+ (should (equal (org-entry-get nil "PRIORITY") "B"))
+ (org-edna-action/set-priority! nil 'up)
+ (should (equal (org-entry-get nil "PRIORITY") "A"))
+ (org-edna-action/set-priority! nil ?C)
+ (should (equal (org-entry-get nil "PRIORITY") "C"))
+ (org-edna-action/set-priority! nil 'remove)
+ (should (equal (org-entry-get nil "PRIORITY") "B")))))
+
+(ert-deftest org-edna-action-effort ()
+ (let ((pom (org-edna-find-test-heading org-edna-test-id-heading-one)))
+ (org-with-point-at pom
+ (org-edna-action/set-effort! nil "0:01")
+ (should (equal (org-entry-get nil "EFFORT") "0:01"))
+ (org-edna-action/set-effort! nil 'increment)
+ (should (equal (org-entry-get nil "EFFORT") "0:02"))
+ (org-entry-delete nil "EFFORT"))))
+
+(ert-deftest org-edna-action-archive ()
+ (let ((org-archive-save-context-info '(todo))
+ (pom (org-edna-find-test-heading org-edna-test-archive-heading))
+ ;; Archive it to the same location
+ (org-archive-location "::** Archive")
+ (org-edna-prompt-for-archive nil))
+ (org-with-point-at pom
+ (org-edna-action/archive! nil)
+ (should (equal (org-entry-get nil "ARCHIVE_TODO") "TODO"))
+ (org-entry-delete nil "ARCHIVE_TODO"))))
+
+(ert-deftest org-edna-action-chain ()
+ (let ((old-pom (org-edna-find-test-heading org-edna-test-id-heading-one))
+ (new-pom (org-edna-find-test-heading org-edna-test-id-heading-two)))
+ (org-entry-put old-pom "TEST" "1")
+ (org-with-point-at new-pom
+ (org-edna-action/chain! old-pom "TEST")
+ (should (equal (org-entry-get nil "TEST") "1")))
+ (org-entry-delete old-pom "TEST")))
+
;; Conditions
diff --git a/org-edna-tests.org b/org-edna-tests.org
index ca881df..0c2c24e 100644
--- a/org-edna-tests.org
+++ b/org-edna-tests.org
@@ -1,3 +1,6 @@
+#+STARTUP: nologdone
+#+PROPERTY: EFFORT_ALL 0:01 0:02 0:03
+
* COMMENT Copying
Copyright (C) 2017 Ian Dunn
@@ -64,6 +67,11 @@ SCHEDULED: <2017-01-01 Sun>
:PROPERTIES:
:ID: 06aca55e-ce09-46df-80d7-5b52e55d6505
:END:
+** Archive
+*** TODO Archive One
+:PROPERTIES:
+:ID: d7668277-f959-43ba-8e85-8a3c76996862
+:END:
* Finder Tests
** Match
*** TODO Blocking Test
diff --git a/org-edna.el b/org-edna.el
index bb99ec4..f980ba9 100644
--- a/org-edna.el
+++ b/org-edna.el
@@ -41,6 +41,11 @@ properties used during actions or conditions."
:group 'org-edna
:type 'boolean)
+(defcustom org-edna-prompt-for-archive t
+ "Whether Edna should prompt before archiving a target."
+ :group 'org-edna
+ :type 'boolean)
+
(defmacro org-edna--syntax-error (msg form pos)
`(signal 'invalid-read-syntax (list :msg ,msg :form ,form :pos ,pos)))
@@ -508,6 +513,10 @@ IDS are all UUIDs as understood by `org-id-find'."
(ignore last-entry)
(org-entry-put nil property value))
+(defun org-edna-action/delete-property! (last-entry property)
+ (ignore last-entry)
+ (org-entry-delete nil property))
+
(defun org-edna-action/clock-in! (last-entry)
(ignore last-entry)
(org-clock-in))
@@ -531,7 +540,9 @@ IDS are all UUIDs as understood by `org-id-find'."
(defun org-edna-action/archive! (last-entry)
(ignore last-entry)
- (org-archive-subtree-default-with-confirmation))
+ (if org-edna-prompt-for-archive
+ (org-archive-subtree-default-with-confirmation)
+ (org-archive-subtree-default)))
(defun org-edna-action/chain! (last-entry property)
(when-let ((old-prop (org-entry-get last-entry property)))
- [elpa] scratch/org-edna 24b323d 52/72: Finished rough draft of documentation, (continued)
- [elpa] scratch/org-edna 24b323d 52/72: Finished rough draft of documentation, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 7517c15 63/72: Use org source blocks instead of example blocks in documentation, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna ce425a3 71/72: Fixed up documentation, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna c62886d 55/72: Updated to new syntax, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 0444691 49/72: Fixed error in last commit, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 9573539 53/72: Added Savannah project link to documentation, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 406f8ea 67/72: Fixed ancestors example, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 69ecfe4 57/72: Added tests for conditions, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 74dae46 51/72: Added tests for finders, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna f56be02 69/72: Silenced byte-compiler, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 8c31160 59/72: Added tests for actions,
Ian Dunn <=
- [elpa] scratch/org-edna 83663fa 64/72: Cleaned up package header and added various docstrings, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 37e9b58 50/72: Fixed chain-find and planning actions, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna ad0f3ef 66/72: Added in-buffer settings and new sections to Documentation, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 3167ea7 39/72: Added check and local settings to Makefile, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 50652ab 58/72: Added installation and setup instructions to documentation, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 191c938 41/72: Added copyright and licensing information to all files, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 7e1dafb 44/72: Fixed license blocks in elisp files, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 831ef13 54/72: Fixed variable-set condition, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna 628869b 56/72: Fixed error reporting, Ian Dunn, 2017/05/21
- [elpa] scratch/org-edna a82892c 47/72: Fixed bugs from last commit, Ian Dunn, 2017/05/21