From d312775f996cd349218d1fcbcec915e4276a126c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 18 Mar 2018 11:09:34 -0400 Subject: [PATCH] TW #1973: Don't nag when no tasks are READY - Thanks to Martin F. Krafft --- AUTHORS | 1 + ChangeLog | 20 +++++++++++--------- src/nag.cpp | 3 ++- test/nag.t | 27 ++++++++++++++++++++++----- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/AUTHORS b/AUTHORS index 6373063c2..eb2e98c5b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -326,3 +326,4 @@ suggestions: Marc Richter rjc php-coder + Martin F. Krafft diff --git a/ChangeLog b/ChangeLog index 1cfe18875..3aa0189a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -69,7 +69,7 @@ Thanks to rjc - TW-1910 unreachable statement Thanks to Martin Strunz -= TW-1917/#1930 "above" does a string comparison, even when the value is numeric +- TW-1917/#1930 "above" does a string comparison, even when the value is numeric Thanks to Dirk Deimeke - TW-1930 Typo in help Thanks to Kai HTML @@ -81,14 +81,16 @@ Thanks to Paul J. Fenwick - TW-1947 "urgency.over" filter seems to not work correct Thanks to Marc Richter -- #1964 task burndown shows extra brackets #1964 - Thanks to php-coder -- #1966 Tests: Don't hardcode errno constants #1966 - Thanks to Jakub Wilk -- #2 Update to markdown and rename DEVELOPER to DEVELOPER.md - Thanks to Lynoure Braakman -- #1 URL formating - Thanks to buhtz +- TW #1964 task burndown shows extra brackets #1964 + Thanks to php-coder +- TW #1966 Tests: Don't hardcode errno constants #1966 + Thanks to Jakub Wilk +- TW #2 Update to markdown and rename DEVELOPER to DEVELOPER.md + Thanks to Lynoure Braakman +- TW #1 URL formating + Thanks to buhtz +- TW #1973 Don't nag when no tasks are READY + Thanks to Martin F. Krafft - Added 'juhannus' as a synonym for 'midsommarafton' Thanks to Lynoure Braakman - Deprecated the 'DUETODAY' virtual tag, which is a synonym for the 'TODAY' diff --git a/src/nag.cpp b/src/nag.cpp index 4b8a1d8ca..880b7e8a8 100644 --- a/src/nag.cpp +++ b/src/nag.cpp @@ -47,8 +47,9 @@ bool nag (Task& task) auto pending = Context::getContext ().tdb2.pending.get_tasks (); for (auto& t : pending) { - if ((t.getStatus () == Task::pending || + if ((t.getStatus () == Task::pending || t.getStatus () == Task::waiting) && + t.hasTag ("READY") && t.urgency () > task.urgency ()) { Context::getContext ().footnote (msg); diff --git a/test/nag.t b/test/nag.t index c970ecdbb..98c982571 100755 --- a/test/nag.t +++ b/test/nag.t @@ -36,11 +36,13 @@ from basetest import Task, TestCase class TestNagging(TestCase): - @classmethod - def setUpClass(cls): - """Executed once before any test in the class""" - cls.t = Task() - cls.t.config("nag", "NAG") + + def setUp(self): + """Executed before each test in the class""" + # Used to initialize objects that should be re-initialized or + # re-created for each individual test + self.t = Task() + self.t.config("nag", "NAG") def test_nagging(self): """Verify that nagging works when tasks are done in the 'wrong' order""" @@ -73,6 +75,21 @@ class TestNagging(TestCase): code, out, err = self.t("1 done") self.assertNotIn("NAG", err) + def test_nagging_ready(self): + """Verify that nagging occurs when there are READY tasks of higher urgency""" + self.t("add one") # low urgency + self.t("add two due:10days scheduled:yesterday") # medium urgency, ready + + code, out, err = self.t("1 done") + self.assertIn("NAG", err) + + def test_nagging_not_ready(self): + """Verify that nagging does not occur when there are unREADY tasks of higher urgency""" + self.t("add one") # low urgency + self.t("add two due:10days scheduled:10days") # medium urgency, not ready + + code, out, err = self.t("1 done") + self.assertNotIn("NAG", err) if __name__ == "__main__": from simpletap import TAPTestRunner