From ffcc574c85bfad792a41f4ef63d10de876cd3f6e Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 12 Aug 2015 21:39:04 -0400 Subject: [PATCH] TW-1653: info report regression; shouldn't be context sensitive - Thanks to David Patrick, Tomas Babej. --- ChangeLog | 2 ++ src/CLI2.cpp | 8 ++--- src/commands/CmdInfo.cpp | 2 +- test/context.t | 76 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93ae33212..d032351be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -121,6 +121,8 @@ - TW-1651 Provide opt-out of filter parser's id treatment (thanks to Daniel Shahaf). - TW-1652 task rm misparsed (thanks to Daniel Shahaf). +- TW-1653 info report regression; shouldn't be context sensitive (thanks to + David Patrick). - Prevent potential task duplication during import for non-pending tasks. - Show the active context in "context list", if any is active. - Fix "task edit" dropping annotation text after newlines. diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 5faa78ca3..ec438207a 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -587,11 +587,11 @@ void CLI2::addContextFilter () // Detect if UUID or ID is set, and bail out for (auto& a : _args) { - if ((a._lextype == Lexer::Type::uuid || - a._lextype == Lexer::Type::set) && - a.hasTag ("FILTER")) + if (a._lextype == Lexer::Type::uuid || + a._lextype == Lexer::Type::number || + a._lextype == Lexer::Type::set) { - context.debug (format ("UUID/ID lexeme found '{1}', not applying context.", a.attribute ("raw"))); + context.debug (format ("UUID/ID argument found '{1}', not applying context.", a.attribute ("raw"))); return; } } diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index a48d1cb1e..415ffddd5 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -54,7 +54,7 @@ CmdInfo::CmdInfo () // Once the test suite is completely modified, this can be corrected. _displays_id = false; _needs_gc = false; - _uses_context = true; + _uses_context = false; _accepts_filter = true; _accepts_modifications = false; _accepts_miscellaneous = false; diff --git a/test/context.t b/test/context.t index 9330900c5..05315dcf0 100755 --- a/test/context.t +++ b/test/context.t @@ -404,6 +404,82 @@ class ContextEvaluationTest(TestCase): self.assertIn("work today task", out) self.assertNotIn("home today task", out) + def test_context_not_applied_on_id_filters(self): + """ + Test that context is not applied when explicit ID + filters are used. + """ + + self.t('context home') + + # Try task not included in context + output = self.t('1 list')[1] + + # Assert that ID filter works even if it does not match the context + self.assertIn("work task", output) + self.assertNotIn("home task", output) + self.assertNotIn("work today task", output) + self.assertNotIn("home today task", output) + + # Try task included in context + output = self.t('2 list')[1] + + # Assert that ID filter works if it does match + # the context (sanity check) + self.assertNotIn("work task", output) + self.assertIn("home task", output) + self.assertNotIn("work today task", output) + self.assertNotIn("home today task", output) + + # Test for combination of IDs + output = self.t('1 2 list')[1] + + # Assert that ID filter works if it partly matches + # and partly does not match the context + self.assertIn("work task", output) + self.assertIn("home task", output) + self.assertNotIn("work today task", output) + self.assertNotIn("home today task", output) + + def test_context_not_applied_on_uuid_filters(self): + """ + Test that context is not applied when explicit UUID + filters are used. + """ + + self.t('context home') + first_uuid = self.t('_get 1.uuid')[1] + second_uuid = self.t('_get 2.uuid')[1] + + # Try task not included in context + output = self.t('%s list' % first_uuid)[1] + + # Assert that UUID filter works even if it does not match + # the context + self.assertIn("work task", output) + self.assertNotIn("home task", output) + self.assertNotIn("work today task", output) + self.assertNotIn("home today task", output) + + # Try task included in context + output = self.t('%s list' % second_uuid)[1] + + # Assert that UUID filter works if it does match + # the context (sanity check) + self.assertNotIn("work task", output) + self.assertIn("home task", output) + self.assertNotIn("work today task", output) + self.assertNotIn("home today task", output) + + # Test for combination of UUIDs + output = self.t('%s %s list' % (first_uuid, second_uuid))[1] + + # Assert that UUID filter works if it partly matches + # and partly does not match the context + self.assertIn("work task", output) + self.assertIn("home task", output) + self.assertNotIn("work today task", output) + self.assertNotIn("home today task", output) # TODO Prove context does not interfere with ID-based filters # TODO Prove context does not interfere with UUID-based filters