mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Add unit tests for new history commands
This commit is contained in:
parent
0c1cfe1492
commit
cd90b8a06d
1 changed files with 66 additions and 0 deletions
|
@ -34,6 +34,72 @@ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|||
|
||||
from basetest import Task, TestCase
|
||||
|
||||
class TestHistoryDaily(TestCase):
|
||||
def setUp(self):
|
||||
"""Executed before each test in the class"""
|
||||
self.t = Task()
|
||||
|
||||
self.data = """[
|
||||
{"uuid":"00000000-0000-0000-0000-000000000000","description":"PLW","status":"pending","entry":"20150102T000000Z","wait":"20150202T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000001","description":"PL","status":"pending","entry":"20150102T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000002","description":"DLN","status":"deleted","entry":"20150102T000000Z","end":"20150202T000000Z","due":"20150202T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000003","description":"DLN2","status":"deleted","entry":"20150102T000000Z","end":"20150202T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000004","description":"DNN","status":"deleted","entry":"20150102T000000Z","end":"20150202T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000005","description":"CLN","status":"completed","entry":"20150102T000000Z","end":"20150202T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000006","description":"CLL","status":"completed","entry":"20150102T000000Z","end":"20150102T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000007","description":"CNN","status":"completed","entry":"20150202T000000Z","end":"20150202T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000008","description":"CNN2","status":"completed","entry":"20150202T000000Z","end":"20150202T000000Z"}
|
||||
]"""
|
||||
self.t("import -", input=self.data)
|
||||
|
||||
def test_history_daily(self):
|
||||
"""Verify 'history.daily' correctly categorizes data"""
|
||||
code, out, err = self.t("history.daily")
|
||||
self.assertRegexpMatches(out, "7\s+1\s+0\s+6")
|
||||
self.assertRegexpMatches(out, "2\s+3\s+3\s+-4")
|
||||
self.assertRegexpMatches(out, "4\s+2\s+1\s+1")
|
||||
|
||||
code, out, err = self.t("ghistory.daily rc._forcecolor:on")
|
||||
self.assertRegexpMatches(out, "\s7.+\s1.+")
|
||||
self.assertRegexpMatches(out, "\s2.+\s3.+\s3.+")
|
||||
|
||||
code, out, err = self.t("ghistory.daily")
|
||||
self.assertRegexpMatches(out, "2015 January 2\s+\++X+\s")
|
||||
self.assertRegexpMatches(out, "\s+February 2\s+\++X+\-+")
|
||||
|
||||
class TestHistoryDaily(TestCase):
|
||||
def setUp(self):
|
||||
"""Executed before each test in the class"""
|
||||
self.t = Task()
|
||||
|
||||
self.data = """[
|
||||
{"uuid":"00000000-0000-0000-0000-000000000000","description":"PLW","status":"pending","entry":"20150102T000000Z","wait":"20150202T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000001","description":"PL","status":"pending","entry":"20150102T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000002","description":"DLN","status":"deleted","entry":"20150102T000000Z","end":"20150202T000000Z","due":"20150202T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000003","description":"DLN2","status":"deleted","entry":"20150102T000000Z","end":"20150202T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000004","description":"DNN","status":"deleted","entry":"20150102T000000Z","end":"20150202T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000005","description":"CLN","status":"completed","entry":"20150102T000000Z","end":"20150202T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000006","description":"CLL","status":"completed","entry":"20150102T000000Z","end":"20150102T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000007","description":"CNN","status":"completed","entry":"20150202T000000Z","end":"20150202T000000Z"},
|
||||
{"uuid":"00000000-0000-0000-0000-000000000008","description":"CNN2","status":"completed","entry":"20150202T000000Z","end":"20150202T000000Z"}
|
||||
]"""
|
||||
self.t("import -", input=self.data)
|
||||
|
||||
def test_history_daily(self):
|
||||
"""Verify 'history.weekly' correctly categorizes data"""
|
||||
code, out, err = self.t("history.weekly")
|
||||
self.assertRegexpMatches(out, "7\s+1\s+0\s+6")
|
||||
self.assertRegexpMatches(out, "2\s+3\s+3\s+-4")
|
||||
self.assertRegexpMatches(out, "4\s+2\s+1\s+1")
|
||||
|
||||
code, out, err = self.t("ghistory.weekly rc._forcecolor:on")
|
||||
self.assertRegexpMatches(out, "\s7.+\s1.+")
|
||||
self.assertRegexpMatches(out, "\s2.+\s3.+\s3.+")
|
||||
|
||||
code, out, err = self.t("ghistory.weekly")
|
||||
self.assertRegexpMatches(out, "2014 December 28\s+\++X+\s")
|
||||
self.assertRegexpMatches(out, "2015 February 1\s+\++X+\-+")
|
||||
|
||||
|
||||
class TestHistoryMonthly(TestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue