mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
test:modify.t: Split tests to for synthetic / non-synthetic intervals
Split the single test for synthetic interval into two separate tests.
This commit is contained in:
parent
845ab2f805
commit
f45734efe0
1 changed files with 50 additions and 46 deletions
|
@ -166,8 +166,8 @@ class TestModify(TestCase):
|
|||
code, out, err = self.t.runError("modify start @1 {:%Y-%m-%dT%H:%M:%S}Z".format(now_utc - timedelta(hours=2)))
|
||||
self.assertIn("You cannot overlap intervals", err)
|
||||
|
||||
def test_modify_move_start_of_synthetic_interval(self):
|
||||
"""Move the start time of synthetic interval forward."""
|
||||
def test_modify_move_start_of_synthetic_interval_with_nonsynethic(self):
|
||||
"""`timew modify` should be able to move start of synthetic interval in presence of non-synthetic intervals."""
|
||||
|
||||
now = datetime.now().replace(second=0, microsecond=0, minute=0)
|
||||
three_hours_before = now - timedelta(hours=3)
|
||||
|
@ -181,10 +181,13 @@ class TestModify(TestCase):
|
|||
|
||||
self.t.configure_exclusions((four_hours_before.time(), three_hours_before.time()))
|
||||
|
||||
# Place a non-synthetic interval in the history
|
||||
# Place a non-synthetic interval in the history before the exclusions
|
||||
self.t("track from {:%Y-%m-%dT%H:%M:%S}Z for 30min bar".format(day_before))
|
||||
self.t("start {:%Y-%m-%dT%H:%M:%S}Z foo".format(five_hours_before_utc))
|
||||
|
||||
# Then modify the synthetic one
|
||||
self.t("modify start @1 {:%Y-%m-%dT%H:%M:%S}Z".format(three_hours_before_utc + timedelta(minutes=10)))
|
||||
|
||||
j = self.t.export()
|
||||
|
||||
self.assertEqual(len(j), 3)
|
||||
|
@ -192,49 +195,7 @@ class TestModify(TestCase):
|
|||
expectedStart=day_before,
|
||||
expectedEnd=day_before + timedelta(minutes=30),
|
||||
expectedTags=[],
|
||||
description="unmodified interval")
|
||||
self.assertClosedInterval(j[1],
|
||||
expectedStart=five_hours_before_utc,
|
||||
expectedEnd=four_hours_before_utc,
|
||||
expectedTags=[],
|
||||
description="unmodified interval")
|
||||
self.assertOpenInterval(j[2],
|
||||
expectedStart=three_hours_before_utc,
|
||||
expectedTags=[],
|
||||
description="unmodified interval")
|
||||
|
||||
# First move the non-synthetic one
|
||||
self.t("modify start @3 {:%Y-%m-%dT%H:%M:%S}Z".format(day_before - timedelta(minutes=30)))
|
||||
|
||||
j = self.t.export()
|
||||
|
||||
self.assertEqual(len(j), 3)
|
||||
self.assertClosedInterval(j[0],
|
||||
expectedStart=day_before - timedelta(minutes=30),
|
||||
expectedEnd=day_before + timedelta(minutes=30),
|
||||
expectedTags=[],
|
||||
description="moved interval")
|
||||
self.assertClosedInterval(j[1],
|
||||
expectedStart=five_hours_before_utc,
|
||||
expectedEnd=four_hours_before_utc,
|
||||
expectedTags=[],
|
||||
description="unmodified interval")
|
||||
self.assertOpenInterval(j[2],
|
||||
expectedStart=three_hours_before_utc,
|
||||
expectedTags=[],
|
||||
description="unmodified interval")
|
||||
|
||||
# Then move the synthetic one
|
||||
self.t("modify start @1 {:%Y-%m-%dT%H:%M:%S}Z".format(three_hours_before_utc + timedelta(minutes=10)))
|
||||
|
||||
j = self.t.export()
|
||||
|
||||
self.assertEqual(len(j), 3)
|
||||
self.assertClosedInterval(j[0],
|
||||
expectedStart=day_before - timedelta(minutes=30),
|
||||
expectedEnd=day_before + timedelta(minutes=30),
|
||||
expectedTags=[],
|
||||
description="moved interval")
|
||||
description="non-synthetic interval")
|
||||
self.assertClosedInterval(j[1],
|
||||
expectedStart=five_hours_before_utc,
|
||||
expectedEnd=four_hours_before_utc,
|
||||
|
@ -245,6 +206,49 @@ class TestModify(TestCase):
|
|||
expectedTags=[],
|
||||
description="moved interval")
|
||||
|
||||
def test_modify_move_start_of_non_synthetic_interval_with_synethic(self):
|
||||
"""`timew modify` should be able to move start of non-synthetic interval in presence of synthetic intervals."""
|
||||
|
||||
now = datetime.now().replace(second=0, microsecond=0, minute=0)
|
||||
three_hours_before = now - timedelta(hours=3)
|
||||
four_hours_before = now - timedelta(hours=4)
|
||||
|
||||
now_utc = now.utcnow().replace(second=0, microsecond=0, minute=0)
|
||||
day_before = now_utc - timedelta(days=1)
|
||||
three_hours_before_utc = now_utc - timedelta(hours=3)
|
||||
four_hours_before_utc = now_utc - timedelta(hours=4)
|
||||
five_hours_before_utc = now_utc - timedelta(hours=5)
|
||||
|
||||
self.t.configure_exclusions((four_hours_before.time(), three_hours_before.time()))
|
||||
|
||||
# Place a non-synthetic interval in the history before the exclusions
|
||||
self.t("track from {:%Y-%m-%dT%H:%M:%S}Z for 30min bar".format(day_before))
|
||||
|
||||
# Open an interval that crosses the exclusions to create two synthetic
|
||||
# intervals
|
||||
self.t("start {:%Y-%m-%dT%H:%M:%S}Z foo".format(five_hours_before_utc))
|
||||
|
||||
# Then modify the non-synthetic one
|
||||
self.t("modify start @3 {:%Y-%m-%dT%H:%M:%S}Z".format(day_before + timedelta(minutes=10)))
|
||||
|
||||
j = self.t.export()
|
||||
|
||||
self.assertEqual(len(j), 3)
|
||||
self.assertClosedInterval(j[0],
|
||||
expectedStart=day_before + timedelta(minutes=10),
|
||||
expectedEnd=day_before + timedelta(minutes=30),
|
||||
expectedTags=[],
|
||||
description="non-synthetic interval")
|
||||
self.assertClosedInterval(j[1],
|
||||
expectedStart=five_hours_before_utc,
|
||||
expectedEnd=four_hours_before_utc,
|
||||
expectedTags=[],
|
||||
description="unmodified interval")
|
||||
self.assertOpenInterval(j[2],
|
||||
expectedStart=three_hours_before_utc,
|
||||
expectedTags=[],
|
||||
description="moved interval")
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue