Add tests for intervals enclosing month borders

This commit is contained in:
Thomas Lauf 2018-09-18 20:09:01 +02:00
parent fef522c53d
commit 2f7e247859
8 changed files with 80 additions and 1 deletions

View file

@ -107,6 +107,15 @@ class TestDelete(TestCase):
expectedTags=['foo'],
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__":
from simpletap import TAPTestRunner

View file

@ -87,6 +87,16 @@ class TestLengthen(TestCase):
expectedTags=[],
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.

View file

@ -186,6 +186,16 @@ class TestMove(TestCase):
expectedTags=[],
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.

View file

@ -2,7 +2,7 @@
# -*- 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
# 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")
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__":
from simpletap import TAPTestRunner

View file

@ -118,6 +118,16 @@ class TestShorten(TestCase):
expectedStart="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__":
from simpletap import TAPTestRunner

View file

@ -220,6 +220,17 @@ class TestStart(TestCase):
self.assertNotIn("Note: 'bar' is a new tag", 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__":
from simpletap import TAPTestRunner

View file

@ -188,6 +188,16 @@ class TestStop(TestCase):
self.assertIn('1150Z', j[1]['start'])
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__":
from simpletap import TAPTestRunner

View file

@ -125,6 +125,15 @@ class TestTrack(TestCase):
self.assertNotIn("Note: 'bar' is a new tag", 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__":
from simpletap import TAPTestRunner