def test_group_by_category(): assert_dpl_cmd_ok(["sum", "--group-by=category"], """2017-09-09 08:00 (a/b/c) foo 09:00 2017-09-11 08:00 (a/b/d) bar 18:00 2017-09-13 08:00 (e/f) More Foo 10:00 (a/x/d) Spam 11:00 (a/x/e) Eggs 12:00 2017-09-12 08:00 (e/f/g) Bar 11:00 """, """ 13h 0m a 11h 0m a/b 1h 0m a/b/c 10h 0m a/b/d 2h 0m a/x 1h 0m a/x/d 1h 0m a/x/e 5h 0m e 5h 0m e/f 3h 0m e/f/g """)
def test_group_by_name(): assert_dpl_cmd_ok(["sum"], """2017-09-09 08:00 A/B/C 09:00 2017-09-11 08:00 A/B/D 18:00 2017-09-13 08:00 E/F 10:00 A/X/D 11:00 A/X/E 12:00 2017-09-12 08:00 E/F/G 11:00 """, """ 1h 0m A/B/C 10h 0m A/B/D 1h 0m A/X/D 1h 0m A/X/E 2h 0m E/F 3h 0m E/F/G """)
def test_work_multiline_comment(): assert_dpl_cmd_ok(["work"], """2017-09-09 08:00 Work item This could be a work item title. Then, it git style, several other comment lines can be added. The following comment can also contain empty lines, which should be preserved. In this way paragraphs can be supported. 09:00 """, """Date: Sat Sep 9 08:00:00 2017 Durance: 1h 0m Work item This could be a work item title. Then, it git style, several other comment lines can be added. The following comment can also contain empty lines, which should be preserved. In this way paragraphs can be supported. """)
def test_date_to_explicit(): assert_dpl_cmd_ok(["work", "--oneline", "--from", "2017-09-09"], """2017-09-09 08:00 Work item 09:00 """, """Sat Sep 9 08:00:00 2017 1h 0m Work item """)
def test_date_space(): assert_dpl_cmd_ok(["tasks", "--oneline"], """2017-09-09 #1 Task 1 08:00 """, """[open] #1 Task 1 """)
def test_work_simple(): assert_dpl_cmd_ok(["work", "--oneline"], """2017-09-09 08:00 Work item 09:00 """, """Sat Sep 9 08:00:00 2017 1h 0m Work item """)
def test_group_by_category_empty(): assert_dpl_cmd_ok(["sum", "--group-by=category"], """2017-09-09 08:00 foo 09:00 """, """ 1h 0m """)
def test_work_category(): assert_dpl_cmd_ok(["work", "--oneline"], """2017-10-15 08:00 (job/coding) Work item 09:00 """, """Sun Oct 15 08:00:00 2017 1h 0m (job/coding) Work item """)
def test_work_oneline_taskref(): assert_dpl_cmd_ok(["work", "--oneline"], """2017-10-15 #1 Task 08:00 Work item Referencing #1. 09:00 """, """Sun Oct 15 08:00:00 2017 1h 0m [open] #1 Work item """)
def test_work_categoryref(): assert_dpl_cmd_ok(["work", "--oneline"], """2017-10-15 #1 (job/coding) Coding 08:00 Work item Referencing #1. 09:00 (job/testing) Test #1 10:00 """, """Sun Oct 15 08:00:00 2017 1h 0m [open] #1 (job/coding) Work item Sun Oct 15 09:00:00 2017 1h 0m [open] #1 (job/testing) Test #1 """)
def test_open_oldertask(): assert_dpl_cmd_ok( ["tasks", "--oneline", "--from", "2017-09-10", "--to", "2017-09-11"], """2017-09-09 #1 Task 1 08:00 2017-09-10 08:00 Unrelated to Task 1 09:00 """, """[open] #1 Task 1 """)
def test_date_range_by_word_1(): assert_dpl_cmd_ok(["tasks", "--oneline", "--to", "yesterday"], """%s #1 yesterday 09:00 %s #2 today 09:00 %s #3 tomorrow 09:00 """ % (YESTERDAY, TODAY, TOMORROW), """[open] #1 yesterday """)
def test_done_oldertask(): assert_dpl_cmd_ok( ["tasks", "--oneline", "--from", "2017-09-10", "--to", "2017-09-11"], """2017-09-09 #1 Task 1 08:00 2017-09-10 08:00 Task 1 Fixes #1. 09:00 """, """[done] #1 Task 1 """)
def test_work_oneline_alignment(): assert_dpl_cmd_ok(["work", "--oneline"], """2017-10-15 08:00 Work item 19:00 2017-11-15 08:00 Work item 09:00 """, """Sun Oct 15 08:00:00 2017 11h 0m Work item Wed Nov 15 08:00:00 2017 1h 0m Work item """)
def test_work_daylight_saving_time(): assert_dpl_cmd_ok(["work", "--oneline"], """2017-10-15 08:00 Work item 09:00 2017-11-15 08:00 Work item 09:00 """, """Sun Oct 15 08:00:00 2017 1h 0m Work item Wed Nov 15 08:00:00 2017 1h 0m Work item """)
def test_desc_indent(): assert_dpl_cmd_ok(["tasks"], """2017-09-09 #1 Task 1 Task name - 1 - 2 - 3 08:00 """, """Id: #1 Status: open Task 1 Task name - 1 - 2 - 3 """)
def test_group_by_day(): assert_dpl_cmd_ok(["sum", "--group-by=day"], """2017-09-09 08:00 Work item 09:00 2017-09-11 08:00 Work item 18:00 2017-09-13 08:00 Work item 10:00 2017-09-12 08:00 Work item 11:00 """, """ 1h 0m 2017-09-09 10h 0m 2017-09-11 3h 0m 2017-09-12 2h 0m 2017-09-13 """)
def test_sorted(): assert_dpl_cmd_ok(["work", "--oneline"], """2017-09-09 08:00 A 09:00 13:00 B 14:00 10:00 C 11:00 2017-09-10 08:00 D 09:00 2017-09-01 08:00 E 09:00 """, """Fri Sep 1 08:00:00 2017 1h 0m E Sat Sep 9 08:00:00 2017 1h 0m A Sat Sep 9 10:00:00 2017 1h 0m C Sat Sep 9 13:00:00 2017 1h 0m B Sun Sep 10 08:00:00 2017 1h 0m D """)
def test_parse_only(): assert_dpl_cmd_ok([], """2017-09-09 08:00 a 09:00 b 10:00 """, "")
def test_version(): assert_dpl_cmd_ok(['--version'], "", """dayplan version %s """ % os.environ['DAYPLAN_VERSION'])
def test_task_category(): assert_dpl_cmd_ok(["tasks", "--oneline"], """2017-09-09 #1 (job/coding) Task 1 08:00 """, """[open] #1 (job/coding) Task 1 """)
def test_empty(): assert_dpl_cmd_ok(["tasks", "--oneline"], "", "")