mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
#9 TI-1: Add test for undo after consecutive starts
This commit is contained in:
parent
3e17dae695
commit
8685a9e2bf
1 changed files with 27 additions and 0 deletions
27
test/undo.t
27
test/undo.t
|
@ -372,6 +372,33 @@ class TestUndo(TestCase):
|
|||
j = self.t.export()
|
||||
self.assertEqual(len(j), 0, msg="Expected 0 interval afterwards, got {}".format(len(j)))
|
||||
|
||||
def test_undo_consecutive_start(self):
|
||||
"""Test undo of consecutive commands 'start'"""
|
||||
now_utc = datetime.now().utcnow()
|
||||
one_hour_before_utc = now_utc - timedelta(hours=1)
|
||||
two_hours_before_utc = now_utc - timedelta(hours=2)
|
||||
|
||||
self.t("start {:%Y%m%dT%H%M%SZ} foo".format(two_hours_before_utc))
|
||||
self.t("start {:%Y%m%dT%H%M%SZ} bar".format(one_hour_before_utc))
|
||||
|
||||
j = self.t.export()
|
||||
self.assertEqual(len(j), 2, msg="Expected 2 intervals before, got {}".format(len(j)))
|
||||
self.assertClosedInterval(j[0],
|
||||
expectedStart=two_hours_before_utc,
|
||||
expectedEnd=one_hour_before_utc,
|
||||
expectedTags=["foo"])
|
||||
self.assertOpenInterval(j[1],
|
||||
expectedStart=one_hour_before_utc,
|
||||
expectedTags=["bar"])
|
||||
|
||||
self.t("undo")
|
||||
|
||||
j = self.t.export()
|
||||
self.assertEqual(len(j), 1, msg="Expected 1 interval afterwards, got {}".format(len(j)))
|
||||
self.assertOpenInterval(j[0],
|
||||
expectedStart=two_hours_before_utc,
|
||||
expectedTags=["foo"])
|
||||
|
||||
def test_undo_stop(self):
|
||||
"""Test undo of command 'stop'"""
|
||||
now_utc = datetime.now().utcnow()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue