mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Fix test summary.t
for single-digit weeks
If summary is called during a single digit week, the respective column is only 2 characters wide Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
parent
b7882fd71f
commit
1a6c30b93a
2 changed files with 28 additions and 12 deletions
|
@ -5,6 +5,7 @@
|
||||||
(thanks to pweaver2019)
|
(thanks to pweaver2019)
|
||||||
- Width determination of Unicode characters now works for up to
|
- Width determination of Unicode characters now works for up to
|
||||||
Unicode 11 (from Unicode 5). Emojis are correctly displayed.
|
Unicode 11 (from Unicode 5). Emojis are correctly displayed.
|
||||||
|
- Fix test `summary.t` for single-digit weeks
|
||||||
|
|
||||||
------ current release ---------------------------
|
------ current release ---------------------------
|
||||||
|
|
||||||
|
|
|
@ -204,16 +204,23 @@ W10 2017-03-09 Thu @4 Tag1 8:43:08 9:38:15 0:55:07
|
||||||
|
|
||||||
code, out, err = self.t("summary :ids :all")
|
code, out, err = self.t("summary :ids :all")
|
||||||
|
|
||||||
|
week_yesterday = yesterday.isocalendar()[1]
|
||||||
|
week_now = now.isocalendar()[1]
|
||||||
|
week_tomorrow = tomorrow.isocalendar()[1]
|
||||||
|
|
||||||
|
two_digit_week = (week_yesterday > 9 | week_now > 9 | week_tomorrow > 9)
|
||||||
|
|
||||||
self.assertIn("""
|
self.assertIn("""
|
||||||
Wk Date Day ID Tags Start End Time Total
|
Wk{6} Date Day ID Tags Start End Time Total
|
||||||
--- ---------- --- -- ---- -------- -------- ------- -------
|
--{7} ---------- --- -- ---- -------- -------- ------- -------
|
||||||
W{3} {0:%Y-%m-%d} {0:%a} @3 FOO 10:00:00 11:00:00 1:00:00 1:00:00
|
W{3} {0:%Y-%m-%d} {0:%a} @3 FOO 10:00:00 11:00:00 1:00:00 1:00:00
|
||||||
W{4} {1:%Y-%m-%d} {1:%a} @2 BAR 10:00:00 11:00:00 1:00:00 1:00:00
|
W{4} {1:%Y-%m-%d} {1:%a} @2 BAR 10:00:00 11:00:00 1:00:00 1:00:00
|
||||||
W{5} {2:%Y-%m-%d} {2:%a} @1 BAZ 10:00:00 11:00:00 1:00:00 1:00:00
|
W{5} {2:%Y-%m-%d} {2:%a} @1 BAZ 10:00:00 11:00:00 1:00:00 1:00:00
|
||||||
|
|
||||||
3:00:00
|
{6} 3:00:00
|
||||||
""".format(yesterday, now, tomorrow,
|
""".format(yesterday, now, tomorrow,
|
||||||
yesterday.isocalendar()[1], now.isocalendar()[1], tomorrow.isocalendar()[1]), out)
|
week_yesterday, week_now, week_tomorrow,
|
||||||
|
" " if two_digit_week is True else "", "-" if two_digit_week is True else ""), out)
|
||||||
|
|
||||||
def test_with_all_hint_and_first_interval_later_in_day(self):
|
def test_with_all_hint_and_first_interval_later_in_day(self):
|
||||||
"""Summary should handle :all hint with first interval that starts later in day than latest interval"""
|
"""Summary should handle :all hint with first interval that starts later in day than latest interval"""
|
||||||
|
@ -241,13 +248,17 @@ W{5} {2:%Y-%m-%d} {2:%a} @1 BAZ 10:00:00 11:00:00 1:00:00 1:00:00
|
||||||
|
|
||||||
code, out, err = self.t("summary :ids yesterday")
|
code, out, err = self.t("summary :ids yesterday")
|
||||||
|
|
||||||
|
week_yesterday = yesterday.isocalendar()[1]
|
||||||
|
|
||||||
|
two_digit_week = (week_yesterday > 9)
|
||||||
|
|
||||||
self.assertIn("""
|
self.assertIn("""
|
||||||
Wk Date Day ID Tags Start End Time Total
|
Wk{2} Date Day ID Tags Start End Time Total
|
||||||
--- ---------- --- -- ---- -------- -------- ------- -------
|
--{3} ---------- --- -- ---- -------- -------- ------- -------
|
||||||
W{1} {0:%Y-%m-%d} {0:%a} @3 FOO 10:00:00 11:00:00 1:00:00 1:00:00
|
W{1} {0:%Y-%m-%d} {0:%a} @3 FOO 10:00:00 11:00:00 1:00:00 1:00:00
|
||||||
|
|
||||||
1:00:00
|
{2} 1:00:00
|
||||||
""".format(yesterday, yesterday.isocalendar()[1]), out)
|
""".format(yesterday, week_yesterday, " " if two_digit_week is True else "", "-" if two_digit_week is True else ""), out)
|
||||||
|
|
||||||
def test_with_named_date_today(self):
|
def test_with_named_date_today(self):
|
||||||
"""Summary should work with 'today'"""
|
"""Summary should work with 'today'"""
|
||||||
|
@ -261,13 +272,17 @@ W{1} {0:%Y-%m-%d} {0:%a} @3 FOO 10:00:00 11:00:00 1:00:00 1:00:00
|
||||||
|
|
||||||
code, out, err = self.t("summary :ids today")
|
code, out, err = self.t("summary :ids today")
|
||||||
|
|
||||||
|
week_now = now.isocalendar()[1]
|
||||||
|
|
||||||
|
two_digit_week = (week_now > 9)
|
||||||
|
|
||||||
self.assertIn("""
|
self.assertIn("""
|
||||||
Wk Date Day ID Tags Start End Time Total
|
Wk{2} Date Day ID Tags Start End Time Total
|
||||||
--- ---------- --- -- ---- -------- -------- ------- -------
|
--{3} ---------- --- -- ---- -------- -------- ------- -------
|
||||||
W{1} {0:%Y-%m-%d} {0:%a} @2 BAR 10:00:00 11:00:00 1:00:00 1:00:00
|
W{1} {0:%Y-%m-%d} {0:%a} @2 BAR 10:00:00 11:00:00 1:00:00 1:00:00
|
||||||
|
|
||||||
1:00:00
|
{2} 1:00:00
|
||||||
""".format(now, now.isocalendar()[1]), out)
|
""".format(now, week_now, " " if two_digit_week is True else "", "-" if two_digit_week is True else ""), out)
|
||||||
|
|
||||||
def test_with_day_gap(self):
|
def test_with_day_gap(self):
|
||||||
"""Summary should skip days with no data"""
|
"""Summary should skip days with no data"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue