mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Test: Drop default confirmation:off and correct tests accordingly
This commit is contained in:
parent
1ad8aa9aec
commit
fe23510c51
24 changed files with 68 additions and 46 deletions
|
@ -49,10 +49,8 @@ class Task(object):
|
|||
|
||||
self.reset_env()
|
||||
|
||||
# Cannot call self.config until confirmation is disabled
|
||||
with open(self.taskrc, 'w') as rc:
|
||||
rc.write("data.location={0}\n"
|
||||
"confirmation=no\n"
|
||||
"hooks=off\n"
|
||||
"".format(self.datadir))
|
||||
|
||||
|
@ -137,7 +135,7 @@ class Task(object):
|
|||
"""
|
||||
# Add -- to avoid misinterpretation of - in things like UUIDs
|
||||
cmd = (self.taskw, "config", "--", var, value)
|
||||
return run_cmd_wait(cmd, env=self.env)
|
||||
return run_cmd_wait(cmd, env=self.env, input="y\n")
|
||||
|
||||
@property
|
||||
def taskrc_content(self):
|
||||
|
|
|
@ -154,7 +154,7 @@ class TestProject(TestBashCompletionBase):
|
|||
code, out, err = self.t("add this task should be number 2 and stay number 2")
|
||||
self.assertIn("Created task 2", out)
|
||||
|
||||
code, out, err = self.t("1 delete")
|
||||
code, out, err = self.t("1 delete", input="y\n")
|
||||
self.assertIn("Deleted 1 task", out)
|
||||
|
||||
with tasksh(self.t):
|
||||
|
|
|
@ -45,7 +45,7 @@ class TestBug954(TestCase):
|
|||
def test_deletion_by_uuid(self):
|
||||
"""Verify deletion using extant UUID"""
|
||||
code, out, err = self.t("_get 1.uuid")
|
||||
code, out, err = self.t(out.strip() + " delete")
|
||||
code, out, err = self.t(out.strip() + " delete", input="y\n")
|
||||
self.assertIn("Deleting task 1 'foo'", out)
|
||||
|
||||
def test_deletion_by_missing_uuid(self):
|
||||
|
|
|
@ -46,7 +46,7 @@ class TestSummaryPercentage(TestCase):
|
|||
self.t("add project:A two")
|
||||
self.t("add project:A three")
|
||||
self.t("1 done")
|
||||
self.t("2 delete")
|
||||
self.t("2 delete", input="y\n")
|
||||
code, out, err = self.t("summary")
|
||||
self.assertIn(" 50%", out)
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class TestBurndownCommand(TestCase):
|
|||
cls.t("add two")
|
||||
cls.t("2 start")
|
||||
cls.t("add three")
|
||||
cls.t("3 delete")
|
||||
cls.t("3 delete", input="y\n")
|
||||
cls.t("add four")
|
||||
cls.t("4 start")
|
||||
cls.t("4 done")
|
||||
|
|
|
@ -191,7 +191,7 @@ class TestStatusFormats(TestCase):
|
|||
|
||||
cls.t("add zero")
|
||||
cls.t("add one")
|
||||
cls.t("2 delete")
|
||||
cls.t("2 delete", input="y\n")
|
||||
cls.t("log two")
|
||||
cls.t("add three due:eom recur:weekly")
|
||||
cls.t("add four wait:eom")
|
||||
|
|
|
@ -47,7 +47,7 @@ class TestCompleted(TestCase):
|
|||
self.t("add two")
|
||||
self.t("add three")
|
||||
self.t("1 done")
|
||||
self.t("2 delete")
|
||||
self.t("2 delete", input="y\n")
|
||||
|
||||
code, out, err = self.t("completed")
|
||||
self.assertIn('one', out)
|
||||
|
|
|
@ -41,6 +41,19 @@ class ContextManagementTest(TestCase):
|
|||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
||||
self.t.config("confirmation", "off")
|
||||
|
||||
def test_context_define_confirmation(self):
|
||||
"""With confirmation active, prompt if context filter matches no tasks"""
|
||||
self.t.config("confirmation", "on")
|
||||
|
||||
code, out, err = self.t.runError('context define work project:Work', timeout=0.2)
|
||||
self.assertIn("The filter 'project:Work' matches 0 pending tasks.", out)
|
||||
self.assertNotIn("Context 'work' defined.", out)
|
||||
|
||||
# Assert the config contains context definition
|
||||
self.assertNotIn('context.work=project:Work\n', self.t.taskrc_content)
|
||||
|
||||
def test_context_define(self):
|
||||
"""Test simple context definition."""
|
||||
code, out, err = self.t('context define work project:Work')
|
||||
|
@ -274,6 +287,8 @@ class ContextEvaluationTest(TestCase):
|
|||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
||||
self.t.config("confirmation", "off")
|
||||
|
||||
# Setup contexts
|
||||
self.t('context define work project:Work')
|
||||
self.t('context define home +home')
|
||||
|
|
|
@ -44,7 +44,7 @@ class TestCount(TestCase):
|
|||
cls.t("add one")
|
||||
cls.t("log two")
|
||||
cls.t("add three")
|
||||
cls.t("1 delete")
|
||||
cls.t("1 delete", input="y\n")
|
||||
|
||||
def test_count_unfiltered(self):
|
||||
code, out, err = self.t("count")
|
||||
|
|
|
@ -46,7 +46,7 @@ class TestDelete(TestCase):
|
|||
code, out, err = self.t("_get 1.uuid")
|
||||
uuid = out.strip()
|
||||
|
||||
self.t("1 delete")
|
||||
self.t("1 delete", input="y\n")
|
||||
self.t.runError("list") # GC/handleRecurrence
|
||||
code, out, err = self.t("_get 1.status")
|
||||
self.assertEqual("\n", out)
|
||||
|
@ -54,7 +54,7 @@ class TestDelete(TestCase):
|
|||
code, out, err = self.t("_get %s.status" % uuid)
|
||||
self.assertIn("deleted\n", out)
|
||||
|
||||
self.t("undo")
|
||||
self.t("undo", input="y\n")
|
||||
code, out, err = self.t("_get 1.status")
|
||||
self.assertIn("pending\n", out)
|
||||
code, out, err = self.t("_get %s.status" % uuid)
|
||||
|
@ -63,7 +63,7 @@ class TestDelete(TestCase):
|
|||
def test_delete_en_passant(self):
|
||||
"""Verify that en-passant works with delete"""
|
||||
self.t("add foo")
|
||||
code, out, err = self.t("1 delete project:work")
|
||||
code, out, err = self.t("1 delete project:work", input="y\n")
|
||||
self.assertIn("Deleted 1 task.", out)
|
||||
|
||||
code, out, err = self.t("all rc.verbose:nothing")
|
||||
|
@ -80,7 +80,7 @@ class TestDelete(TestCase):
|
|||
|
||||
self.t("all") # GC/handleRecurrence
|
||||
|
||||
code, out, err = self.t("%s delete" % uuid)
|
||||
code, out, err = self.t("%s delete" % uuid, input="y\n")
|
||||
self.assertIn("Deleted 1 task.", out)
|
||||
|
||||
code, out, err = self.t("_get %s.status" % uuid)
|
||||
|
@ -90,7 +90,7 @@ class TestDelete(TestCase):
|
|||
"""Delete prompt with closed STDIN causes infinite loop and floods stdout (single)"""
|
||||
self.t("add foo1")
|
||||
|
||||
self._validate_prompt_loop()
|
||||
self._validate_prompt_loop(input="y\n")
|
||||
|
||||
def test_delete_bulk_prompt_loop(self):
|
||||
"""Delete prompt with closed STDIN causes infinite loop and floods stdout (bulk)"""
|
||||
|
@ -99,12 +99,12 @@ class TestDelete(TestCase):
|
|||
self.t("add foo2")
|
||||
self.t("add foo3")
|
||||
|
||||
self._validate_prompt_loop()
|
||||
self._validate_prompt_loop(input="y\n")
|
||||
|
||||
def _validate_prompt_loop(self):
|
||||
def _validate_prompt_loop(self, input=""):
|
||||
"""Helper method to check if task flooded stream on closed STDIN"""
|
||||
try:
|
||||
code, out, err = self.t("/foo[1-3]/ delete", input="", timeout=0.2)
|
||||
code, out, err = self.t("/foo[1-3]/ delete", input=input, timeout=0.2)
|
||||
except CommandError as e:
|
||||
# If delete fails with a timeout, don't fail the test immediately
|
||||
code, out, err = e.code, e.out, e.err
|
||||
|
|
|
@ -164,8 +164,9 @@ class TestDependencies(TestCase):
|
|||
|
||||
# 3 <-- 4 Deleting 4 requires no repair
|
||||
# 3
|
||||
code, out, err = self.t("4 delete")
|
||||
code, out, err = self.t("4 delete", input="y\n")
|
||||
self.assertNotIn("Would you like the dependency chain fixed?", out)
|
||||
self.assertIn("Deleted 1 task", out)
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_id_range_dep(self):
|
||||
|
|
|
@ -84,6 +84,8 @@ class TestEnpassant(BaseTestEnpassant):
|
|||
def setUp(self):
|
||||
super(TestEnpassant, self).setUp()
|
||||
|
||||
self.t.config("confirmation", "off")
|
||||
|
||||
self.t("add one")
|
||||
self.t("add two")
|
||||
self.t("add three")
|
||||
|
|
|
@ -58,7 +58,7 @@ class TestFeature725(TestCase):
|
|||
self.assertIn("Unblocked", out)
|
||||
|
||||
# 1 does unblock 4.
|
||||
code, out, er = self.t("1 delete")
|
||||
code, out, er = self.t("1 delete", input="y\n")
|
||||
self.assertIn("Unblocked", out)
|
||||
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ class TestImport(TestCase):
|
|||
def test_import_update(self):
|
||||
"""Update existing tasks"""
|
||||
self.t("import", input=self.data1)
|
||||
self.t("a1111111-a111-a111-a111-a11111111111 delete")
|
||||
self.t("a1111111-a111-a111-a111-a11111111111 delete", input="y\n")
|
||||
self.t("next") # Run GC
|
||||
|
||||
_t = sorted(self.t.export(), key=lambda t: t["uuid"])
|
||||
|
|
|
@ -49,7 +49,7 @@ class TestProjects(TestCase):
|
|||
self.t("add project:A 1")
|
||||
self.t("add project:B 2")
|
||||
self.t("add project:B 3")
|
||||
self.t("3 delete")
|
||||
self.t("3 delete", input="y\n")
|
||||
code, out, err = self.t("project:B projects")
|
||||
|
||||
expected = "1 project \(1 task\)"
|
||||
|
@ -78,7 +78,7 @@ class TestProjects(TestCase):
|
|||
self.assertRegexpMatches(err, self.STATUS.format("foo", "25%",
|
||||
"3 of 4 tasks"))
|
||||
|
||||
code, out, err = self.t("2 delete")
|
||||
code, out, err = self.t("2 delete", input="y\n")
|
||||
self.assertRegexpMatches(err, self.STATUS.format("foo", "33%",
|
||||
"2 of 3 tasks"))
|
||||
|
||||
|
@ -156,7 +156,7 @@ class TestProjects(TestCase):
|
|||
"""Verify _projects helper list projects"""
|
||||
self.t("add project:A one")
|
||||
self.t("add project:B two")
|
||||
self.t("2 delete")
|
||||
self.t("2 delete", input="y\n")
|
||||
self.t("log project:C three")
|
||||
self.t("list")
|
||||
|
||||
|
@ -170,6 +170,7 @@ class TestProjects(TestCase):
|
|||
self.assertIn("B", out)
|
||||
self.assertIn("C", out)
|
||||
|
||||
|
||||
class TestBug299(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
@ -245,6 +246,7 @@ class TestBug605(TestCase):
|
|||
code, out, err = self.t("2 done")
|
||||
self.assertIn("is 100% complete", err)
|
||||
|
||||
|
||||
class TestBug906(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
@ -278,6 +280,7 @@ class TestBug906(TestCase):
|
|||
self.assertNotIn("one", out)
|
||||
self.assertIn("two", out)
|
||||
|
||||
|
||||
class TestBug856(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
@ -302,6 +305,7 @@ class TestBug856(TestCase):
|
|||
self.assertIn("floating", out)
|
||||
self.assertNotIn("assigned", out)
|
||||
|
||||
|
||||
class TestBug1511(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
@ -317,6 +321,7 @@ class TestBug1511(TestCase):
|
|||
self.assertIn("one", out)
|
||||
self.assertNotIn("zero", out)
|
||||
|
||||
|
||||
class TestBug1455(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
|
|
@ -194,7 +194,7 @@ class TestRecurrenceTasks(TestCase):
|
|||
self.assertEqual("complex3\n", out)
|
||||
|
||||
# Delete a child task, do not propagate.
|
||||
code, out, err = self.t("3 delete", input="n\n")
|
||||
code, out, err = self.t("3 delete", input="y\n")
|
||||
self.assertIn("Deleted 1 task.", out)
|
||||
|
||||
# Delete a child task, propagate.
|
||||
|
@ -229,7 +229,7 @@ class TestDeletionRecurrence(TestCase):
|
|||
"""Delete a parent with child tasks"""
|
||||
self.t("add one due:eom recur:daily")
|
||||
self.t("list") # GC/handleRecurrence
|
||||
code, out, err = self.t("1 delete", input="y\n")
|
||||
code, out, err = self.t("1 delete", input="y\ny\n")
|
||||
self.assertIn("Deleted 2 tasks.", out)
|
||||
|
||||
code, out, err = self.t.runError("list")
|
||||
|
@ -242,7 +242,7 @@ class TestDeletionRecurrence(TestCase):
|
|||
code, out, err = self.t("list rc.verbose:nothing") # GC/handleRecurrence
|
||||
self.assertEqual(out.count("one"), 5)
|
||||
|
||||
code, out, err = self.t("2 delete", input="y\n")
|
||||
code, out, err = self.t("2 delete", input="y\ny\n")
|
||||
self.assertIn("Deleted 5 tasks.", out)
|
||||
|
||||
|
||||
|
@ -312,7 +312,6 @@ class TestBug955(TestCase):
|
|||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_no_prompt_for_parent_on_child_delete(self):
|
||||
"""Deleting a child of a recurring task doesn't prompt for parent deletion
|
||||
|
||||
|
@ -322,13 +321,7 @@ class TestBug955(TestCase):
|
|||
code, out, err = self.t("ls")
|
||||
self.assertRegexpMatches(out, re.compile("^2 tasks", re.MULTILINE))
|
||||
|
||||
# NOTE: Test fails here due to some strange handling of STDIN in task
|
||||
# "y\nn\n" actually behaves as "y\ny\n" so both tasks are deleted
|
||||
# in the shell 'printf "y\nn\n" | task 2 delete' works as expected.
|
||||
# Yet replacing the task binary with something like "hexdump", all
|
||||
# bytes received via STDIN are identical in python vs shell.
|
||||
# NOTE: This may be related to delete.t test_delete_bulk_prompt_loop
|
||||
code, out, err = self.t("2 delete", input="y\nn\n")
|
||||
code, out, err = self.t("2 delete", input="n\ny\n")
|
||||
self.assertIn("Deleting task 2", out)
|
||||
self.assertIn("Deleted 1 task", out)
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class TestSequences(TestCase):
|
|||
|
||||
def test_sequence_delete(self):
|
||||
"""Test sequences in delete"""
|
||||
self.t("1,2 delete")
|
||||
self.t("1,2 delete", input="y\ny\n")
|
||||
code, out, err = self.t("_get 1.status 2.status")
|
||||
self.assertEqual("deleted deleted\n", out)
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ class TestActiveTaskHandling(TestCase):
|
|||
|
||||
def test_start_deleted(self):
|
||||
"""Deleted task set to pending by start"""
|
||||
self.t("+one delete")
|
||||
self.t("+one delete", input="y\n")
|
||||
self.t("+one start")
|
||||
tl = self.t.export()
|
||||
self.assertEqual(tl[0]["status"], "pending")
|
||||
|
|
|
@ -44,7 +44,7 @@ class TestStatisticsCommand(TestCase):
|
|||
"""Verify stats records task states"""
|
||||
self.t("add one")
|
||||
self.t("add two")
|
||||
self.t("2 delete")
|
||||
self.t("2 delete", input="y\n")
|
||||
self.t("log three")
|
||||
|
||||
code, out, err = self.t("stats")
|
||||
|
|
|
@ -50,7 +50,7 @@ class TestTags(TestCase):
|
|||
code, out, err = self.t("_get 1.tags")
|
||||
self.assertEqual("one,two,three\n", out)
|
||||
|
||||
# Remove tags.
|
||||
# Remove tags.
|
||||
self.t("1 modify -three -two -one")
|
||||
code, out, err = self.t("_get 1.tags")
|
||||
self.assertEqual("\n", out)
|
||||
|
@ -74,6 +74,7 @@ class TestTags(TestCase):
|
|||
code, out, err = self.t("1 modify -missing")
|
||||
self.assertIn("Modified 0 tasks", out)
|
||||
|
||||
|
||||
class TestVirtualTags(TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -82,7 +83,7 @@ class TestVirtualTags(TestCase):
|
|||
cls.t.config("verbose", "nothing")
|
||||
cls.t("log completed")
|
||||
cls.t("add deleted")
|
||||
cls.t("1 delete")
|
||||
cls.t("1 delete", input="y\n")
|
||||
cls.t("add minimal")
|
||||
cls.t("add maximal +tag pro:PRO pri:H due:yesterday")
|
||||
cls.t("3 start")
|
||||
|
@ -480,7 +481,7 @@ class TestListAllTags(TestCase):
|
|||
self.t("add +t1 one")
|
||||
self.t("add +t2 two")
|
||||
self.t("1 done")
|
||||
self.t("list") # GC/handleRecurrence
|
||||
self.t("list") # GC/handleRecurrence
|
||||
|
||||
code, out, err = self.t("rc.verbose:nothing tags")
|
||||
self.assertNotIn("t1", out)
|
||||
|
|
|
@ -153,7 +153,7 @@ class TestBug1379(TestCase):
|
|||
self.t.config("color.deleted", "")
|
||||
|
||||
self.t("add Delete")
|
||||
self.t("1 delete")
|
||||
self.t("1 delete", input="y\n")
|
||||
|
||||
code, out, err = self.t("all +DELETED")
|
||||
self.assertRegexpMatches(out, self.RED + r".*Delete.*" + self.CLEAR)
|
||||
|
|
|
@ -42,7 +42,14 @@ class TestBug1475(TestCase):
|
|||
|
||||
def test_config_unmolested(self):
|
||||
"""Verify that a config value is not borked by lex/eval"""
|
||||
self.t("config name one/two/three")
|
||||
self.t.config("name", "one/two/three")
|
||||
|
||||
code, out, err = self.t("_get rc.name")
|
||||
self.assertEqual("one/two/three\n", out)
|
||||
|
||||
def test_config_unmolested_2(self):
|
||||
"""Verify that a config value is not borked by lex/eval - literal"""
|
||||
self.t("config name one/two/three", input="y\n")
|
||||
|
||||
code, out, err = self.t("_get rc.name")
|
||||
self.assertEqual("one/two/three\n", out)
|
||||
|
|
|
@ -45,7 +45,7 @@ class TestUndo(TestCase):
|
|||
self.t('add one')
|
||||
code, out, err = self.t('_get 1.status')
|
||||
self.assertEqual(out.strip(), 'pending')
|
||||
self.t('undo')
|
||||
self.t('undo', input="y\n")
|
||||
code, out, err = self.t('_get 1.status')
|
||||
self.assertEqual(out.strip(), '')
|
||||
|
||||
|
@ -57,7 +57,7 @@ class TestUndo(TestCase):
|
|||
self.t('1 done')
|
||||
code, out, err = self.t('_get 1.status')
|
||||
self.assertEqual(out.strip(), 'completed')
|
||||
self.t('undo')
|
||||
self.t('undo', input="y\n")
|
||||
code, out, err = self.t('_get 1.status')
|
||||
self.assertEqual(out.strip(), 'pending')
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class TestUnique(TestCase):
|
|||
self.t("add two project:A")
|
||||
self.t("add three project:B")
|
||||
self.t("add four project:C")
|
||||
self.t("4 delete")
|
||||
self.t("4 delete", input="y\n")
|
||||
self.t("log five project:D")
|
||||
|
||||
code, out, err = self.t("_unique project")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue