mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
#111 Make move.t run on any time
This commit is contained in:
parent
f18e105c71
commit
3e9bd1113d
1 changed files with 17 additions and 8 deletions
21
test/move.t
21
test/move.t
|
@ -51,6 +51,7 @@ from basetest import Timew, TestCase
|
||||||
# self.assertNotRegexpMatches(text, pattern)
|
# self.assertNotRegexpMatches(text, pattern)
|
||||||
# self.tap("")
|
# self.tap("")
|
||||||
|
|
||||||
|
|
||||||
class TestMove(TestCase):
|
class TestMove(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Executed before each test in the class"""
|
"""Executed before each test in the class"""
|
||||||
|
@ -84,9 +85,11 @@ class TestMove(TestCase):
|
||||||
|
|
||||||
def test_move_open_backwards_to_specific_time(self):
|
def test_move_open_backwards_to_specific_time(self):
|
||||||
"""Move an open interval backwards to specific time."""
|
"""Move an open interval backwards to specific time."""
|
||||||
|
one_hour_before = datetime.now() - timedelta(hours=1)
|
||||||
|
|
||||||
self.t("start 5mins ago foo")
|
self.t("start 5mins ago foo")
|
||||||
code, out, err = self.t("move @1 12:01am")
|
code, out, err = self.t("move @1 {:%Y-%m-%dT%H}:01:23".format(one_hour_before))
|
||||||
self.assertRegexpMatches(out, 'Moved @1 to \d\d\d\d-\d\d-\d\dT00:01:00')
|
self.assertRegexpMatches(out, "Moved @1 to {:%Y-%m-%dT%H}:01:23".format(one_hour_before))
|
||||||
|
|
||||||
j = self.t.export()
|
j = self.t.export()
|
||||||
self.assertEqual(len(j), 1)
|
self.assertEqual(len(j), 1)
|
||||||
|
@ -151,6 +154,9 @@ class TestMove(TestCase):
|
||||||
four_hours_before = now - timedelta(hours=4)
|
four_hours_before = now - timedelta(hours=4)
|
||||||
five_hours_before = now - timedelta(hours=5)
|
five_hours_before = now - timedelta(hours=5)
|
||||||
|
|
||||||
|
if four_hours_before.day < three_hours_before.day:
|
||||||
|
exclusion = "<{:%H}:00 >{:%H}:00".format(three_hours_before, four_hours_before)
|
||||||
|
else:
|
||||||
exclusion = "{:%H}:00-{:%H}:00".format(four_hours_before, three_hours_before)
|
exclusion = "{:%H}:00-{:%H}:00".format(four_hours_before, three_hours_before)
|
||||||
|
|
||||||
self.t.config("exclusions.friday", exclusion)
|
self.t.config("exclusions.friday", exclusion)
|
||||||
|
@ -161,9 +167,9 @@ class TestMove(TestCase):
|
||||||
self.t.config("exclusions.sunday", exclusion)
|
self.t.config("exclusions.sunday", exclusion)
|
||||||
self.t.config("exclusions.saturday", exclusion)
|
self.t.config("exclusions.saturday", exclusion)
|
||||||
|
|
||||||
self.t("start {}T{:%H}:45:00".format(now.date(), five_hours_before))
|
self.t("start {:%Y-%m-%dT%H}:45:00".format(five_hours_before))
|
||||||
|
|
||||||
self.t("move @2 {}T{:%H}:50:00".format(now.date(), five_hours_before))
|
self.t("move @2 {:%Y-%m-%dT%H}:50:00".format(five_hours_before))
|
||||||
|
|
||||||
j = self.t.export()
|
j = self.t.export()
|
||||||
|
|
||||||
|
@ -187,6 +193,9 @@ class TestMove(TestCase):
|
||||||
four_hours_before = now - timedelta(hours=4)
|
four_hours_before = now - timedelta(hours=4)
|
||||||
five_hours_before = now - timedelta(hours=5)
|
five_hours_before = now - timedelta(hours=5)
|
||||||
|
|
||||||
|
if four_hours_before.day < three_hours_before.day:
|
||||||
|
exclusion = "<{:%H}:00 >{:%H}:00".format(three_hours_before, four_hours_before)
|
||||||
|
else:
|
||||||
exclusion = "{:%H}:00-{:%H}:00".format(four_hours_before, three_hours_before)
|
exclusion = "{:%H}:00-{:%H}:00".format(four_hours_before, three_hours_before)
|
||||||
|
|
||||||
self.t.config("exclusions.friday", exclusion)
|
self.t.config("exclusions.friday", exclusion)
|
||||||
|
@ -197,9 +206,9 @@ class TestMove(TestCase):
|
||||||
self.t.config("exclusions.sunday", exclusion)
|
self.t.config("exclusions.sunday", exclusion)
|
||||||
self.t.config("exclusions.saturday", exclusion)
|
self.t.config("exclusions.saturday", exclusion)
|
||||||
|
|
||||||
self.t("start {}T{:%H}:45:00".format(now.date(), five_hours_before))
|
self.t("start {:%Y-%m-%dT%H}:45:00".format(five_hours_before))
|
||||||
|
|
||||||
self.t("move @2 {}T{:%H}:40:00".format(now.date(), five_hours_before))
|
self.t("move @2 {:%Y-%m-%dT%H}:40:00".format(five_hours_before))
|
||||||
|
|
||||||
j = self.t.export()
|
j = self.t.export()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue