mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Improve delete.t
- Use interval asserts
This commit is contained in:
parent
d5d82f02fa
commit
3cec514c2d
1 changed files with 12 additions and 15 deletions
|
@ -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
|
||||
|
@ -52,11 +52,9 @@ class TestDelete(TestCase):
|
|||
self.assertEqual(out, 'Deleted @1\n')
|
||||
|
||||
j = self.t.export()
|
||||
|
||||
self.assertEqual(len(j), 1)
|
||||
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.assertClosedInterval(j[0], expectedTags=["foo"])
|
||||
|
||||
def test_delete_closed(self):
|
||||
"""Delete a single closed interval"""
|
||||
|
@ -66,11 +64,9 @@ class TestDelete(TestCase):
|
|||
self.assertEqual(out, 'Deleted @2\n')
|
||||
|
||||
j = self.t.export()
|
||||
|
||||
self.assertEqual(len(j), 1)
|
||||
self.assertTrue('start' in j[0])
|
||||
self.assertFalse('end' in j[0])
|
||||
self.assertTrue('tags' in j[0])
|
||||
self.assertEqual(j[0]['tags'][0], 'bar')
|
||||
self.assertOpenInterval(j[0], expectedTags=["bar"])
|
||||
|
||||
def test_delete_multiple(self):
|
||||
"""Delete a mix of open/closed intervals"""
|
||||
|
@ -90,7 +86,9 @@ class TestDelete(TestCase):
|
|||
|
||||
three_hours_before = now - timedelta(hours=3)
|
||||
four_hours_before = now - timedelta(hours=4)
|
||||
five_hours_before = now - timedelta(hours=5)
|
||||
|
||||
four_hours_before_utc = now_utc - timedelta(hours=4)
|
||||
five_hours_before_utc = now_utc - timedelta(hours=5)
|
||||
|
||||
if four_hours_before.day < three_hours_before.day:
|
||||
exclusion = "<{:%H}:00 >{:%H}:00".format(three_hours_before, four_hours_before)
|
||||
|
@ -105,20 +103,19 @@ class TestDelete(TestCase):
|
|||
self.t.config("exclusions.friday", exclusion)
|
||||
self.t.config("exclusions.saturday", exclusion)
|
||||
|
||||
self.t("start {:%Y-%m-%dT%H}:00:00 foo".format(five_hours_before))
|
||||
self.t("start {:%Y-%m-%dT%H}:00:00Z foo".format(five_hours_before_utc))
|
||||
|
||||
# Delete the open interval.
|
||||
code, out, err = self.t("delete @1") # self.t("delete @1 :debug")
|
||||
print(out)
|
||||
self.assertEqual(out, 'Deleted @1\n')
|
||||
|
||||
# The last interval should be closed, because the open interval was deleted.
|
||||
j = self.t.export()
|
||||
print(j)
|
||||
|
||||
self.assertEqual(len(j), 1)
|
||||
self.assertClosedInterval(j[0],
|
||||
expectedStart='{:%Y%m%dT%H}0000Z'.format(now_utc-timedelta(hours=5)),
|
||||
expectedEnd='{:%Y%m%dT%H}0000Z'.format(now_utc-timedelta(hours=4)),
|
||||
expectedStart='{:%Y%m%dT%H}0000Z'.format(five_hours_before_utc),
|
||||
expectedEnd='{:%Y%m%dT%H}0000Z'.format(four_hours_before_utc),
|
||||
expectedTags=['foo'],
|
||||
description='remaining interval')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue