Use Taskchampion to store Taskwarrior data
This replaces the TF2 task files with a TaskChampion replica.
This commit is contained in:
committed by
Dustin J. Mitchell
parent
4b814bc602
commit
5bb9857984
1
test/.gitignore
vendored
1
test/.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
*.o
|
||||
*.pyc
|
||||
*.data
|
||||
*.sqlite3
|
||||
*.log
|
||||
*.runlog
|
||||
col.t
|
||||
|
||||
@@ -13,6 +13,7 @@ include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src/commands
|
||||
${CMAKE_SOURCE_DIR}/src/columns
|
||||
${CMAKE_SOURCE_DIR}/src/libshared/src
|
||||
${CMAKE_SOURCE_DIR}/src/taskchampion/lib
|
||||
${CMAKE_SOURCE_DIR}/test
|
||||
${CMAKE_SOURCE_DIR}/taskchampion/lib
|
||||
${TASK_INCLUDE_DIRS})
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
###############################################################################
|
||||
#
|
||||
# Copyright 2006 - 2021, Tomas Babej, Paul Beckingham, Federico Hernandez.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
# https://www.opensource.org/licenses/mit-license.php
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
|
||||
# Ensure python finds the local simpletap module
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from basetest import Task, TestCase
|
||||
|
||||
|
||||
class Test1510(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
||||
def assertNoEmptyValueInBacklog(self, attribute_name):
|
||||
backlog_path = os.path.join(self.t.datadir, 'backlog.data')
|
||||
with open(backlog_path) as backlog:
|
||||
empty_value = '"%s":""' % attribute_name
|
||||
self.assertFalse(any(empty_value in line
|
||||
for line in backlog.readlines()))
|
||||
|
||||
def test_no_empty_value_for_deleted_due_in_backlog(self):
|
||||
"""
|
||||
1510: Make sure deleted due attribute does not get into
|
||||
backlog.data with empty string value
|
||||
"""
|
||||
|
||||
self.t('add test due:2015-05-05')
|
||||
self.t('1 mod due:')
|
||||
self.assertNoEmptyValueInBacklog('due')
|
||||
|
||||
def test_no_empty_value_for_empty_priority_in_backlog(self):
|
||||
"""
|
||||
1510: Make sure empty priority attribute does not get into
|
||||
backlog.data with empty string value
|
||||
"""
|
||||
|
||||
self.t('add test pri:""')
|
||||
self.t("add test2 pri:''")
|
||||
self.t("add test3 pri:")
|
||||
self.t("add test4 pri:H")
|
||||
self.assertNoEmptyValueInBacklog('priority')
|
||||
|
||||
def test_no_empty_value_for_empty_project_in_backlog(self):
|
||||
"""
|
||||
1510: Make sure empty project attribute does not get into
|
||||
backlog.data with empty string value
|
||||
"""
|
||||
|
||||
self.t('add test project:""')
|
||||
self.t("add test2 project:''")
|
||||
self.t("add test3 project:")
|
||||
self.t("add test4 project:random")
|
||||
self.assertNoEmptyValueInBacklog('project')
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
||||
# vim: ai sts=4 et sw=4 ft=python
|
||||
@@ -68,7 +68,7 @@ class TestFeature559(TestCase):
|
||||
code, out, err = self.t.runError("rc.data.location=locationdoesnotexist list")
|
||||
self.assertNotIn("footask", out)
|
||||
self.assertNotIn("Error", out)
|
||||
self.assertRegex(err, re.compile("Error:.+does not exist", re.DOTALL))
|
||||
self.assertRegex(err, re.compile("Could not.+unable to open database file", re.DOTALL))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -128,7 +128,8 @@ class TestIDRangeParsing(TestCase):
|
||||
with tempfile.NamedTemporaryFile(mode='w') as f:
|
||||
f.write('\n'.join([f'{{"description": "test task {i+1}"}}' for i in range(n)]))
|
||||
f.flush()
|
||||
code, out, err = self.t(f'import {f.name}')
|
||||
# use a long timeout here, because import is quite slow
|
||||
code, out, err = self.t(f'import {f.name}', timeout=100)
|
||||
|
||||
def test_single_digit_range(self):
|
||||
"""Test that parsing single digit ID range works"""
|
||||
|
||||
@@ -377,6 +377,7 @@ class TestUpgradeToRecurring(TestCase):
|
||||
|
||||
def test_upgrade(self):
|
||||
"""Upgrade task to recurring"""
|
||||
# note that this functionality is implemented in Task::validate
|
||||
self.t("add foo")
|
||||
self.t("1 modify due:tomorrow recur:weekly")
|
||||
code, out, err = self.t("_get 1.status")
|
||||
|
||||
@@ -77,7 +77,7 @@ int main (int, char**)
|
||||
t.ok(maybe_task2.has_value(), "task lookup by uuid finds task");
|
||||
t.is ((*maybe_task2).get_description (), std::string ("a test"), "task description round-trip");
|
||||
|
||||
rep.rebuild_working_set ();
|
||||
rep.rebuild_working_set (true);
|
||||
t.pass ("rebuild_working_set");
|
||||
|
||||
auto tasks = rep.all_tasks ();
|
||||
|
||||
@@ -60,7 +60,7 @@ int main (int, char**)
|
||||
context.config.set ("gc", 1);
|
||||
context.config.set ("debug", 1);
|
||||
|
||||
context.tdb2.set_location (".");
|
||||
context.tdb2.open_replica (".", true);
|
||||
|
||||
// Try reading an empty database.
|
||||
std::vector <Task> pending = context.tdb2.pending_tasks ();
|
||||
@@ -104,7 +104,7 @@ int main (int, char**)
|
||||
|
||||
// Reset for reuse.
|
||||
cleardb ();
|
||||
context.tdb2.set_location (".");
|
||||
context.tdb2.open_replica (".", true);
|
||||
|
||||
// TODO commit
|
||||
// TODO complete a task
|
||||
|
||||
@@ -14,5 +14,5 @@ task log two depends:1
|
||||
|
||||
task /two/ export > JSON
|
||||
|
||||
rm pending.data completed.data
|
||||
rm taskchampion.sqlite3
|
||||
task import JSON
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# This tests the migration path from 2.5.3 or earlier to 2.6.0 with respect to
|
||||
# the upgrade of the status field from waiting to pending
|
||||
. bash_tap_tw.sh
|
||||
|
||||
# Setup
|
||||
task add Actionable task wait:yesterday
|
||||
task add Non-actionable task wait:tomorrow+1h
|
||||
|
||||
# Simulate this was created in 2.5.3 or earlier (status is equal to waiting,
|
||||
# not pending). Using more cumbersome sed syntax for Mac OS-X compatibility.
|
||||
sed -i".bak" 's/pending/waiting/g' $TASKDATA/pending.data
|
||||
rm -f $TASKDATA/pending.data.bak
|
||||
|
||||
# Trigger upgrade
|
||||
task all
|
||||
|
||||
# Report file content
|
||||
echo pending.data
|
||||
cat $TASKDATA/pending.data
|
||||
echo completed.data
|
||||
cat $TASKDATA/completed.data
|
||||
|
||||
# Assertion: Exactly one task is considered waiting
|
||||
[[ `task +WAITING count` == "1" ]]
|
||||
[[ `task status:waiting count` == "1" ]]
|
||||
|
||||
# Assertion: Exactly one task is considered pending
|
||||
[[ `task +PENDING count` == "1" ]]
|
||||
[[ `task status:pending count` == "1" ]]
|
||||
|
||||
# Assertion: Task 1 is pending
|
||||
[[ `task _get 1.status` == "pending" ]]
|
||||
|
||||
# Assertion: Task 2 is waiting
|
||||
[[ `task _get 2.status` == "waiting" ]]
|
||||
|
||||
# Assertion: No lines in data files with "waiting" status
|
||||
[[ -z `cat $TASKDATA/pending.data | grep waiting` ]]
|
||||
[[ -z `cat $TASKDATA/completed.data | grep waiting` ]]
|
||||
|
||||
# Assertion: No tasks were moved into completed.data
|
||||
cat $TASKDATA/pending.data | wc -l | tr -d ' '
|
||||
[[ `cat $TASKDATA/pending.data | wc -l | tr -d ' '` == "2" ]]
|
||||
[[ `cat $TASKDATA/completed.data | wc -l | tr -d ' '` == "0" ]]
|
||||
58
test/tw-46.t
58
test/tw-46.t
@@ -1,58 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
###############################################################################
|
||||
#
|
||||
# Copyright 2006 - 2021, Tomas Babej, Paul Beckingham, Federico Hernandez.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
# https://www.opensource.org/licenses/mit-license.php
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
# Ensure python finds the local simpletap module
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from basetest import Task, TestCase
|
||||
|
||||
|
||||
class TestBug46(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
self.t("add one")
|
||||
self.t("add two")
|
||||
self.t("add three")
|
||||
|
||||
def test_bug46(self):
|
||||
"""Circular dependency detection broken by deletion of completed.data"""
|
||||
self.t("1 mod dep:2")
|
||||
self.t("2 delete", input="y\n")
|
||||
self.t("rc.gc=on list")
|
||||
os.remove(os.path.join(self.t.datadir, "completed.data"))
|
||||
self.t("1 mod dep:2")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
||||
# vim: ai sts=4 et sw=4 ft=python
|
||||
@@ -102,7 +102,8 @@ class TestBug634(TestCase):
|
||||
|
||||
# If a prompt happens, the test will timeout on input (exitcode != 0)
|
||||
code, out, err = self.t("rc.confirmation=off undo")
|
||||
self.assertIn("Task removed", out)
|
||||
code, out, err = self.t("_get 1.description")
|
||||
self.assertEqual(out.strip(), '') # task is gone
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
21
test/uuid.t
21
test/uuid.t
@@ -179,15 +179,28 @@ class TestUUIDuplicates(TestCase):
|
||||
"""Executed before each test in the class"""
|
||||
self.t = Task()
|
||||
|
||||
def test_uuid_duplicates(self):
|
||||
"""Verify that duplicating tasks, and recurring tasks do no create duplicates UUIDs"""
|
||||
def test_uuid_duplicates_dupe(self):
|
||||
"""Verify that duplicating tasks does not create duplicate UUIDs"""
|
||||
self.t("add simple")
|
||||
self.t("1 duplicate")
|
||||
self.t("add periodic recur:daily due:yesterday")
|
||||
|
||||
uuids = list()
|
||||
for id in range(1,3):
|
||||
code, out, err = self.t("_get %d.uuid" % id)
|
||||
uuids.append(out.strip())
|
||||
|
||||
self.assertEqual(len(uuids), len(set(uuids)))
|
||||
|
||||
code, out, err = self.t("diag")
|
||||
self.assertIn("No duplicates found", out)
|
||||
|
||||
def test_uuid_duplicates_recurrence(self):
|
||||
"""Verify that recurring tasks do not create duplicate UUIDs"""
|
||||
print(self.t("add periodic recur:daily due:yesterday"))
|
||||
self.t("list") # GC/handleRecurrence
|
||||
|
||||
uuids = list()
|
||||
for id in range(1,7):
|
||||
for id in range(1,5):
|
||||
code, out, err = self.t("_get %d.uuid" % id)
|
||||
uuids.append(out.strip())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user