mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Update tests
This commit is contained in:
parent
9b5793206f
commit
7771d94dee
4 changed files with 118 additions and 30 deletions
30
test/start.t
30
test/start.t
|
@ -30,7 +30,7 @@ import os
|
|||
import sys
|
||||
import unittest
|
||||
|
||||
from datetime import time
|
||||
from datetime import datetime, timedelta, time
|
||||
|
||||
# Ensure python finds the local simpletap module
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
@ -192,6 +192,34 @@ class TestStart(TestCase):
|
|||
self.assertIn('1150Z', j[1]['start'])
|
||||
self.assertIn('4422Z', j[1]['end'])
|
||||
|
||||
def test_start_with_new_tag(self):
|
||||
"""Call 'start' with new tag"""
|
||||
now_utc = datetime.now().utcnow()
|
||||
|
||||
two_hours_before_utc = now_utc - timedelta(hours=2)
|
||||
one_hour_before_utc = now_utc - timedelta(hours=1)
|
||||
|
||||
self.t("track {:%Y-%m-%dT%H:%M:%S} - {:%Y-%m-%dT%H:%M:%S} foo".format(two_hours_before_utc, one_hour_before_utc))
|
||||
code, out, err = self.t("start {:%Y-%m-%dT%H:%M:%S} bar".format(now_utc))
|
||||
|
||||
self.assertIn("Note: 'bar' is a new tag", out)
|
||||
self.assertIn("Tracking bar", out)
|
||||
|
||||
def test_start_with_previous_tag(self):
|
||||
"""Call 'start' with previous tag"""
|
||||
now_utc = datetime.now().utcnow()
|
||||
|
||||
three_hours_before_utc = now_utc - timedelta(hours=3)
|
||||
two_hours_before_utc = now_utc - timedelta(hours=2)
|
||||
one_hour_before_utc = now_utc - timedelta(hours=1)
|
||||
|
||||
self.t("track {:%Y-%m-%dT%H:%M:%S} - {:%Y-%m-%dT%H:%M:%S} bar".format(three_hours_before_utc, two_hours_before_utc))
|
||||
self.t("track {:%Y-%m-%dT%H:%M:%S} - {:%Y-%m-%dT%H:%M:%S} foo".format(two_hours_before_utc, one_hour_before_utc))
|
||||
code, out, err = self.t("start {:%Y-%m-%dT%H:%M:%S} bar".format(now_utc))
|
||||
|
||||
self.assertNotIn("Note: 'bar' is a new tag", out)
|
||||
self.assertIn("Tracking bar", out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue