mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Add tests for intervals enclosing month borders
This commit is contained in:
parent
fef522c53d
commit
2f7e247859
8 changed files with 80 additions and 1 deletions
|
@ -107,6 +107,15 @@ class TestDelete(TestCase):
|
||||||
expectedTags=['foo'],
|
expectedTags=['foo'],
|
||||||
description='remaining interval')
|
description='remaining interval')
|
||||||
|
|
||||||
|
def test_delete_interval_which_encloses_month_border(self):
|
||||||
|
"""Delete an interval which encloses a month border"""
|
||||||
|
self.t("track 20180831T220000 - 20180901T030000 foo")
|
||||||
|
self.t("delete @1")
|
||||||
|
|
||||||
|
j = self.t.export()
|
||||||
|
|
||||||
|
self.assertEqual(len(j), 0)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from simpletap import TAPTestRunner
|
from simpletap import TAPTestRunner
|
||||||
|
|
|
@ -87,6 +87,16 @@ class TestLengthen(TestCase):
|
||||||
expectedTags=[],
|
expectedTags=[],
|
||||||
description="unmodified interval")
|
description="unmodified interval")
|
||||||
|
|
||||||
|
def test_lengthen_an_interval_to_enclose_a_month_border(self):
|
||||||
|
"""Lengthen an interval to enclose a month border"""
|
||||||
|
self.t("track 20180831T220000 - 20180831T230000 foo")
|
||||||
|
self.t("lengthen @1 4h")
|
||||||
|
|
||||||
|
j = self.t.export()
|
||||||
|
|
||||||
|
self.assertEqual(len(j), 1)
|
||||||
|
self.assertClosedInterval(j[0])
|
||||||
|
|
||||||
# TODO Add :adjust tests.
|
# TODO Add :adjust tests.
|
||||||
|
|
||||||
|
|
||||||
|
|
10
test/move.t
10
test/move.t
|
@ -186,6 +186,16 @@ class TestMove(TestCase):
|
||||||
expectedTags=[],
|
expectedTags=[],
|
||||||
description="unmodified interval")
|
description="unmodified interval")
|
||||||
|
|
||||||
|
def test_move_interval_to_enclose_a_month_border(self):
|
||||||
|
"""Move an interval to enclose a month border"""
|
||||||
|
self.t("track 20180831T180000 - 20180831T230000 foo")
|
||||||
|
self.t("move @1 20180831T220000")
|
||||||
|
|
||||||
|
j = self.t.export()
|
||||||
|
|
||||||
|
self.assertEqual(len(j), 1)
|
||||||
|
self.assertClosedInterval(j[0])
|
||||||
|
|
||||||
# TODO Add :adjust tests.
|
# TODO Add :adjust tests.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
# Copyright 2006 - 2018, Paul Beckingham, Federico Hernandez.
|
# Copyright 2006 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -60,6 +60,16 @@ class TestResize(TestCase):
|
||||||
code, out, err = self.t("resize @1 1month")
|
code, out, err = self.t("resize @1 1month")
|
||||||
self.assertIn('Resized @1 to 720:00:00', out)
|
self.assertIn('Resized @1 to 720:00:00', out)
|
||||||
|
|
||||||
|
def test_resize_interval_to_enclose_month_border(self):
|
||||||
|
"""Resize an interval to enclose a month border"""
|
||||||
|
self.t("track 20180831T220000 - 20180831T230000 foo")
|
||||||
|
self.t("resize @1 3h")
|
||||||
|
|
||||||
|
j = self.t.export()
|
||||||
|
|
||||||
|
self.assertEqual(len(j), 1)
|
||||||
|
self.assertClosedInterval(j[0])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from simpletap import TAPTestRunner
|
from simpletap import TAPTestRunner
|
||||||
|
|
|
@ -118,6 +118,16 @@ class TestShorten(TestCase):
|
||||||
expectedStart="20160608T073000Z",
|
expectedStart="20160608T073000Z",
|
||||||
expectedEnd="20160608T073000Z")
|
expectedEnd="20160608T073000Z")
|
||||||
|
|
||||||
|
def test_shorten_an_interval_which_encloses_month_border(self):
|
||||||
|
"""Shorten an interval which encloses a month border"""
|
||||||
|
self.t("track 20180831T220000 - 20180901T030000 foo")
|
||||||
|
self.t("shorten @1 4h")
|
||||||
|
|
||||||
|
j = self.t.export()
|
||||||
|
|
||||||
|
self.assertEqual(len(j), 1)
|
||||||
|
self.assertClosedInterval(j[0])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from simpletap import TAPTestRunner
|
from simpletap import TAPTestRunner
|
||||||
|
|
11
test/start.t
11
test/start.t
|
@ -220,6 +220,17 @@ class TestStart(TestCase):
|
||||||
self.assertNotIn("Note: 'bar' is a new tag", out)
|
self.assertNotIn("Note: 'bar' is a new tag", out)
|
||||||
self.assertIn("Tracking bar", out)
|
self.assertIn("Tracking bar", out)
|
||||||
|
|
||||||
|
def test_start_tracking_of_interval_which_encloses_month_border(self):
|
||||||
|
"""Start tracking after an interval which encloses a month border"""
|
||||||
|
self.t("start 20180831T220000 foo")
|
||||||
|
self.t("start 20180901T030000 bar")
|
||||||
|
|
||||||
|
j = self.t.export()
|
||||||
|
|
||||||
|
self.assertEqual(len(j), 2)
|
||||||
|
self.assertClosedInterval(j[0])
|
||||||
|
self.assertOpenInterval(j[1])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from simpletap import TAPTestRunner
|
from simpletap import TAPTestRunner
|
||||||
|
|
10
test/stop.t
10
test/stop.t
|
@ -188,6 +188,16 @@ class TestStop(TestCase):
|
||||||
self.assertIn('1150Z', j[1]['start'])
|
self.assertIn('1150Z', j[1]['start'])
|
||||||
self.assertIn('4422Z', j[1]['end'])
|
self.assertIn('4422Z', j[1]['end'])
|
||||||
|
|
||||||
|
def test_stop_tracking_of_interval_which_encloses_month_border(self):
|
||||||
|
"""Stop tracking of an interval which encloses a month border"""
|
||||||
|
self.t("start 20180831T220000 foo")
|
||||||
|
self.t("stop 20180901T030000")
|
||||||
|
|
||||||
|
j = self.t.export()
|
||||||
|
|
||||||
|
self.assertEqual(len(j), 1)
|
||||||
|
self.assertClosedInterval(j[0])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from simpletap import TAPTestRunner
|
from simpletap import TAPTestRunner
|
||||||
|
|
|
@ -125,6 +125,15 @@ class TestTrack(TestCase):
|
||||||
self.assertNotIn("Note: 'bar' is a new tag", out)
|
self.assertNotIn("Note: 'bar' is a new tag", out)
|
||||||
self.assertIn("Recorded bar", out)
|
self.assertIn("Recorded bar", out)
|
||||||
|
|
||||||
|
def test_track_interval_which_encloses_month_border(self):
|
||||||
|
"""Track an interval which encloses a month border"""
|
||||||
|
self.t("track 20180831T220000 - 20180901T030000 foo")
|
||||||
|
|
||||||
|
j = self.t.export()
|
||||||
|
|
||||||
|
self.assertEqual(len(j), 1)
|
||||||
|
self.assertClosedInterval(j[0])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from simpletap import TAPTestRunner
|
from simpletap import TAPTestRunner
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue