mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 09:53:08 +02:00
Add unit-tests to verify fix for 1904
This commit is contained in:
parent
28974cd794
commit
9c89870c71
2 changed files with 77 additions and 0 deletions
|
@ -481,6 +481,45 @@ class TestBug1627(TestCase):
|
||||||
self.assertEqual("mon\n", out)
|
self.assertEqual("mon\n", out)
|
||||||
|
|
||||||
|
|
||||||
|
class TestBug1904(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
"""Executed before each test in the class"""
|
||||||
|
self.t = Task()
|
||||||
|
|
||||||
|
def add_tasks(self):
|
||||||
|
self.t("add pro:a-b test1")
|
||||||
|
self.t("add pro:a.b test2")
|
||||||
|
|
||||||
|
def validate_order(self, out):
|
||||||
|
order = (
|
||||||
|
"a",
|
||||||
|
" b",
|
||||||
|
"a-b",
|
||||||
|
)
|
||||||
|
|
||||||
|
lines = out.splitlines(True)
|
||||||
|
# position where project names start on the lines list
|
||||||
|
position = 3
|
||||||
|
|
||||||
|
for i, proj in enumerate(order):
|
||||||
|
pos = position + i
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
lines[pos].startswith(proj),
|
||||||
|
msg=("Project '{0}' is not in line #{1} or has an unexpected "
|
||||||
|
"indentation.{2}".format(proj, pos, out))
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_project_eval(self):
|
||||||
|
"""1904: verify correct order under projects command"""
|
||||||
|
self.add_tasks()
|
||||||
|
|
||||||
|
code, out, err = self.t("projects")
|
||||||
|
|
||||||
|
self.validate_order(out)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from simpletap import TAPTestRunner
|
from simpletap import TAPTestRunner
|
||||||
unittest.main(testRunner=TAPTestRunner())
|
unittest.main(testRunner=TAPTestRunner())
|
||||||
|
|
|
@ -63,6 +63,44 @@ class TestSummaryPercentage(TestCase):
|
||||||
self.assertIn("No projects.", out)
|
self.assertIn("No projects.", out)
|
||||||
|
|
||||||
|
|
||||||
|
class TestBug1904(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
"""Executed before each test in the class"""
|
||||||
|
self.t = Task()
|
||||||
|
|
||||||
|
def add_tasks(self):
|
||||||
|
self.t("add pro:a-b test1")
|
||||||
|
self.t("add pro:a.b test2")
|
||||||
|
|
||||||
|
def validate_order(self, out):
|
||||||
|
order = (
|
||||||
|
"a",
|
||||||
|
" b",
|
||||||
|
"a-b",
|
||||||
|
)
|
||||||
|
|
||||||
|
lines = out.splitlines(True)
|
||||||
|
# position where project names start on the lines list
|
||||||
|
position = 3
|
||||||
|
|
||||||
|
for i, proj in enumerate(order):
|
||||||
|
pos = position + i
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
lines[pos].startswith(proj),
|
||||||
|
msg=("Project '{0}' is not in line #{1} or has an unexpected "
|
||||||
|
"indentation.{2}".format(proj, pos, out))
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_project_eval(self):
|
||||||
|
"""1904: verify correct order under summary command"""
|
||||||
|
self.add_tasks()
|
||||||
|
|
||||||
|
code, out, err = self.t("summary")
|
||||||
|
|
||||||
|
self.validate_order(out)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from simpletap import TAPTestRunner
|
from simpletap import TAPTestRunner
|
||||||
unittest.main(testRunner=TAPTestRunner())
|
unittest.main(testRunner=TAPTestRunner())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue