mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Refactor test
- allow for jitter to stabilize test - use triple quote strings
This commit is contained in:
parent
55508fd201
commit
946ac0ad68
1 changed files with 40 additions and 11 deletions
|
@ -75,7 +75,15 @@ temp.report.end: 20160101T080000Z
|
|||
]\
|
||||
""")
|
||||
|
||||
self.assertEqual('\nTotal by Tag, for 2016-01-01 07:00:00 - 2016-01-01 08:00:00\n\nTag Total\n----- ----------\nfoo 1:00:00\n ----------\nTotal 1:00:00\n', out)
|
||||
self.assertRegexpMatches(out, """
|
||||
Total by Tag, for 2016-01-01 07:00:00 - 2016-01-01 08:00:00
|
||||
|
||||
Tag Total
|
||||
----- ----------
|
||||
foo 1:00:0[01]
|
||||
----------
|
||||
Total 1:00:0[01]
|
||||
""")
|
||||
self.assertEqual('', err)
|
||||
|
||||
def test_totals_with_interval_without_tags(self):
|
||||
|
@ -89,7 +97,15 @@ temp.report.end: 20160101T080000Z
|
|||
[{"start":"20160101T070000Z","end":"20160101T080000Z"}]\
|
||||
""")
|
||||
|
||||
self.assertEqual('\nTotal by Tag, for 2016-01-01 07:00:00 - 2016-01-01 08:00:00\n\nTag Total\n----- ----------\n 1:00:00\n ----------\nTotal 1:00:00\n', out)
|
||||
self.assertRegexpMatches(out, """
|
||||
Total by Tag, for 2016-01-01 07:00:00 - 2016-01-01 08:00:00
|
||||
|
||||
Tag Total
|
||||
----- ----------
|
||||
1:00:0[01]
|
||||
----------
|
||||
Total 1:00:0[01]
|
||||
""")
|
||||
self.assertEqual('', err)
|
||||
|
||||
def test_totals_with_interval_with_empty_tag_list(self):
|
||||
|
@ -105,32 +121,45 @@ temp.report.end: 20160101T080000Z
|
|||
]\
|
||||
""")
|
||||
|
||||
self.assertEqual('\nTotal by Tag, for 2016-01-01 07:00:00 - 2016-01-01 08:00:00\n\nTag Total\n----- ----------\n 1:00:00\n ----------\nTotal 1:00:00\n', out)
|
||||
self.assertRegexpMatches(out, """
|
||||
Total by Tag, for 2016-01-01 07:00:00 - 2016-01-01 08:00:00
|
||||
|
||||
Tag Total
|
||||
----- ----------
|
||||
1:00:0[01]
|
||||
----------
|
||||
Total 1:00:0[01]
|
||||
""")
|
||||
self.assertEqual('', err)
|
||||
|
||||
def test_totals_with_open_interval(self):
|
||||
"""totals extension should handle open interval"""
|
||||
now = datetime.datetime.now()
|
||||
now_utc = now.utcnow()
|
||||
|
||||
one_hour_before = now - datetime.timedelta(hours=1)
|
||||
two_hours_before = now - datetime.timedelta(hours=2)
|
||||
|
||||
now_utc = now.utcnow()
|
||||
one_hour_before_utc = now_utc - datetime.timedelta(hours=1)
|
||||
two_hours_before_utc = now_utc - datetime.timedelta(hours=2)
|
||||
|
||||
out, err = self.process.communicate(input="""\
|
||||
color: off
|
||||
debug: off
|
||||
temp.report.start: {:%Y%m%dT%H%M%S}Z
|
||||
temp.report.start: {0:%Y%m%dT%H%M%S}Z
|
||||
temp.report.end:
|
||||
|
||||
[
|
||||
{{"start":"{:%Y%m%dT%H%M%S}Z","tags":["foo"]}}
|
||||
{{"start":"{0:%Y%m%dT%H%M%S}Z","tags":["foo"]}}
|
||||
]\
|
||||
""".format(one_hour_before_utc, one_hour_before_utc))
|
||||
""".format(one_hour_before_utc))
|
||||
|
||||
self.assertEqual('\nTotal by Tag, for {:%Y-%m-%d %H:%M:%S} - {:%Y-%m-%d %H:%M:%S}\n\nTag Total\n----- ----------\nfoo 1:00:00\n ----------\nTotal 1:00:00\n'.format(two_hours_before, now), out)
|
||||
self.assertRegexpMatches(out, """
|
||||
Total by Tag, for {:%Y-%m-%d %H:%M}:0[01] - {:%Y-%m-%d %H:%M}:0[01]
|
||||
|
||||
Tag Total
|
||||
----- ----------
|
||||
foo 1:00:0[01]
|
||||
----------
|
||||
Total 1:00:0[01]
|
||||
""".format(two_hours_before, now))
|
||||
self.assertEqual('', err)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue