mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
TI-102: Add tests
This commit is contained in:
parent
8e2e350cab
commit
7e9fe82fc3
4 changed files with 374 additions and 8 deletions
122
test/stop.t
122
test/stop.t
|
@ -26,10 +26,10 @@
|
|||
#
|
||||
###############################################################################
|
||||
|
||||
import sys
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from datetime import datetime
|
||||
|
||||
# Ensure python finds the local simpletap module
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
@ -51,6 +51,7 @@ from basetest import Timew, TestCase
|
|||
# self.assertNotRegexpMatches(text, pattern)
|
||||
# self.tap("")
|
||||
|
||||
|
||||
class TestStop(TestCase):
|
||||
def setUp(self):
|
||||
"""Executed before each test in the class"""
|
||||
|
@ -108,6 +109,123 @@ class TestStop(TestCase):
|
|||
code, out, err = self.t.runError("stop four")
|
||||
self.assertIn("The current interval does not have the 'four' tag.", err)
|
||||
|
||||
def test_single_interval_enclosing_exclusion(self):
|
||||
"""Add one interval that encloseѕ an exclusion, and is therefore flattened"""
|
||||
self.t.config("exclusions.monday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.tuesday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.wednesday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.thursday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.friday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.saturday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.sunday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
|
||||
self.t("start 20160101T100000 foo")
|
||||
self.t("stop 20160101T150000")
|
||||
|
||||
j = self.t.export()
|
||||
self.assertEqual(len(j), 2)
|
||||
|
||||
self.assertTrue('start' in j[0])
|
||||
self.assertTrue('end' in j[0])
|
||||
self.assertTrue('tags' in j[0])
|
||||
self.assertEqual(j[0]['tags'][0], 'foo')
|
||||
|
||||
self.assertTrue('start' in j[1])
|
||||
self.assertTrue('end' in j[1])
|
||||
self.assertTrue('tags' in j[1])
|
||||
self.assertEqual(j[1]['tags'][0], 'foo')
|
||||
|
||||
def test_single_interval_starting_within_an_exclusion_and_enclosing_an_exclusion(self):
|
||||
"""Add one interval that starts within an exclusion and encloses an exclusion"""
|
||||
self.t.config("exclusions.monday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.tuesday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.wednesday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.thursday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.friday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.saturday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.sunday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
|
||||
self.t("start 20160101T082255 foo")
|
||||
self.t("stop 20160101T144422") # stop, so foo gets closed and flattened
|
||||
|
||||
j = self.t.export()
|
||||
self.assertEqual(len(j), 2)
|
||||
|
||||
self.assertTrue('start' in j[0])
|
||||
self.assertIn('2255Z', j[0]['start'])
|
||||
self.assertTrue('end' in j[0])
|
||||
self.assertIn('2244Z', j[0]['end'])
|
||||
self.assertTrue('tags' in j[0])
|
||||
self.assertEqual(j[0]['tags'][0], 'foo')
|
||||
|
||||
self.assertTrue('start' in j[1])
|
||||
self.assertIn('3223Z', j[1]['start'])
|
||||
self.assertTrue('end' in j[1])
|
||||
self.assertIn('4422Z', j[1]['end'])
|
||||
self.assertTrue('tags' in j[1])
|
||||
self.assertEqual(j[1]['tags'][0], 'foo')
|
||||
|
||||
def test_single_interval_ending_within_an_exclusion_and_enclosing_an_exclusion(self):
|
||||
"""Add one interval that ends within an exclusion and encloses an exclusion"""
|
||||
self.t.config("exclusions.monday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.tuesday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.wednesday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.thursday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.friday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.saturday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.sunday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
|
||||
self.t("start 20160101T102255 foo")
|
||||
self.t("stop 20160101T194422") # stop, so foo gets closed and flattened
|
||||
|
||||
j = self.t.export()
|
||||
self.assertEqual(len(j), 2)
|
||||
|
||||
self.assertTrue('start' in j[0])
|
||||
self.assertIn('2255Z', j[0]['start'])
|
||||
self.assertTrue('end' in j[0])
|
||||
self.assertIn('2244Z', j[0]['end'])
|
||||
self.assertTrue('tags' in j[0])
|
||||
self.assertEqual(j[0]['tags'][0], 'foo')
|
||||
|
||||
self.assertTrue('start' in j[1])
|
||||
self.assertIn('3223Z', j[1]['start'])
|
||||
self.assertTrue('end' in j[1])
|
||||
self.assertIn('4422Z', j[1]['end'])
|
||||
self.assertTrue('tags' in j[1])
|
||||
self.assertEqual(j[1]['tags'][0], 'foo')
|
||||
|
||||
def test_single_interval_and_enclosing_an_exclusion_with_day_change(self):
|
||||
"""Add one interval that encloses an exclusion with day change"""
|
||||
self.t.config("exclusions.monday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.tuesday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.wednesday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.thursday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.friday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.saturday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
self.t.config("exclusions.sunday", "<9:11:50 12:22:44-13:32:23 >18:05:11")
|
||||
|
||||
self.t("start 20160101T172255 foo")
|
||||
self.t("stop 20160102T104422") # stop, so foo gets closed and flattened
|
||||
|
||||
j = self.t.export()
|
||||
self.assertEqual(len(j), 2)
|
||||
|
||||
self.assertTrue('start' in j[0])
|
||||
self.assertIn('2255Z', j[0]['start'])
|
||||
self.assertTrue('end' in j[0])
|
||||
self.assertIn('0511Z', j[0]['end'])
|
||||
self.assertTrue('tags' in j[0])
|
||||
self.assertEqual(j[0]['tags'][0], 'foo')
|
||||
|
||||
self.assertTrue('start' in j[1])
|
||||
self.assertIn('1150Z', j[1]['start'])
|
||||
self.assertTrue('end' in j[1])
|
||||
self.assertIn('4422Z', j[1]['end'])
|
||||
self.assertTrue('tags' in j[1])
|
||||
self.assertEqual(j[1]['tags'][0], 'foo')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue