コード例 #1
0
 def test_both_empty(self):
     first = make_file("")
     second = make_file("")
     result = append_files(first, second)
     expected = ""
     assert result.read() == expected
     assert first.read() == ""
     assert second.read() == ""
コード例 #2
0
 def test_happy(self):
     first = make_file("Hi ")
     second = make_file("there")
     result = append_files(first, second)
     expected = "Hi there"
     assert result.read() == expected
     assert first.read() == "Hi "
     assert second.read() == "there"
コード例 #3
0
 def test_missing_agenda_raises_error(self, planner):
     mock_get_logfile = MagicMock()
     mock_get_logfile.return_value = make_file(
         "[ ] a task\n[\\] another task")
     planner._get_logfile = mock_get_logfile
     with pytest.raises(LogfileLayoutError):
         planner.update_agenda(Day, "[ ] new task\n")
コード例 #4
0
 def test_this_week(self, tasklist):
     today = datetime.date(2013, 2, 14)
     original = self._tasklist()
     tasklist.file = make_file(original)
     task = "[o] something [$FEBRUARY 16, 2013$]\n"
     expected = self._tasklist(task, Week)
     tasklist.place_tasks([task], today)
     assert tasklist.file.getvalue() == expected
コード例 #5
0
 def test_someday(self, tasklist):
     today = datetime.date(2013, 2, 14)
     original = self._tasklist()
     tasklist.file = make_file(original)
     task = "[o] something [$SOMEDAY$]\n"
     expected = self._tasklist(task, Eternity)
     tasklist.place_tasks([task], today)
     assert tasklist.file.getvalue() == expected
コード例 #6
0
 def test_this_year(self, tasklist):
     today = datetime.date(2013, 2, 14)
     original = self._tasklist()
     tasklist.file = make_file(original)
     task = "[o] something [$JULY 18, 2013$]\n"
     expected = self._tasklist(task, Year)
     tasklist.place_tasks([task], today)
     assert tasklist.file.getvalue() == expected
コード例 #7
0
 def test_past_due_placed_in_tomorrow(self, tasklist):
     today = datetime.date(2013, 2, 14)
     original = self._tasklist()
     tasklist.file = make_file(original)
     task = "[o] something [$FEBRUARY 12, 2013$]\n"
     expected = self._tasklist(task, Day)
     tasklist.place_tasks([task], today)
     assert tasklist.file.getvalue() == expected
コード例 #8
0
 def test_miscategorized_month_to_quarter(self, tasklist):
     task = "[o] something [$MARCH 26, 2013$]\n"
     original = self._tasklist(task, Month)
     tasklist.file = make_file(original)
     today = datetime.date(2013, 2, 14)
     tomorrow = today + timedelta(days=1)
     tasklist.advance(tomorrow)
     expected = self._tasklist(task, Quarter)
     assert tasklist.file.getvalue() == expected
コード例 #9
0
 def test_miscategorized_tomorrow_to_quarter(self, tasklist):
     task = "[o] something [$FEBRUARY 15, 2013$]\n"
     original = self._tasklist(task, Day)
     tasklist.file = make_file(original)
     today = datetime.date(2013, 1, 1)
     tomorrow = today + timedelta(days=1)
     tasklist.advance(tomorrow)
     expected = self._tasklist(task, Quarter)
     assert tasklist.file.getvalue() == expected
コード例 #10
0
 def test_tomorrow(self, tasklist):
     today = datetime.date(2013, 2, 14)
     task = "[o] something [$TOMORROW$]\n"
     original = self._tasklist(task, Day)
     tasklist.file = make_file(original)
     standardized_task = "[o] something [$FEBRUARY 15, 2013$]\n"
     expected = self._tasklist(standardized_task, Day)
     tasklist.standardize_entries(today)
     assert tasklist.file.getvalue() == expected
コード例 #11
0
 def test_miscategorized_year_to_later(self, tasklist):
     task = "[o] something [$JULY 26, 2013$]\n"
     original = self._tasklist(task, Year)
     tasklist.file = make_file(original)
     today = datetime.date(2012, 12, 1)
     tomorrow = today + timedelta(days=1)
     tasklist.advance(tomorrow)
     expected = self._tasklist(task, Eternity)
     assert tasklist.file.getvalue() == expected
コード例 #12
0
 def test_task_with_subtasks(self, logfile):
     for _ in range(6):
         logfile.readline()
     file = make_file(logfile.read())
     entry, _ = read_entry(file)
     expected = ("[ ] a task with subtasks\n"
                 "\t[ ] first thing\n"
                 "\tclarification of first thing\n"
                 "\t[ ] second thing\n")
     assert entry == expected
コード例 #13
0
 def test_file_containing_only_section(self):
     contents = "AGENDA:\n[ ] do this\n[\\] another thing\n"
     new_tasks = "[ ] one more thing to do!\n"
     file = make_file(contents)
     updated = add_to_section(file,
                              'AGENDA',
                              new_tasks,
                              above=False,
                              ensure_separator=True)
     expected = contents + new_tasks
     assert updated.read() == expected
コード例 #14
0
 def test_tasks_ordered_chronologically_within_section(self, tasklist):
     today = datetime.date(2013, 2, 14)
     original = self._tasklist()
     tasklist.file = make_file(original)
     tasks = [
         "[o] something [$JULY 18, 2013$]\n",
         "[o] something else [$JULY 17, 2013$]\n",
         "[o] something too [$JULY 19, 2013$]\n",
     ]
     tasklist.place_tasks(tasks, today)
     result = tasklist.file.getvalue()
     assert (result.index(tasks[1]) < result.index(tasks[0]) < result.index(
         tasks[2]))
コード例 #15
0
 def test_advance_by_year(self, tasklist):
     tomorrow = datetime.date(2014, 1, 1)
     original = self._calendar_tasklist()
     tasklist.file = make_file(original)
     tasklist.advance(tomorrow)
     expected = ("TOMORROW:\n"
                 "[o] do tomorrow [$FEBRUARY 12, 2013$]\n"
                 "[o] do this week [$FEBRUARY 16, 2013$]\n"
                 "[o] do this month [$FEBRUARY 28, 2013$]\n"
                 "[o] do this quarter [$MARCH 11, 2013$]\n"
                 "[o] do this year [$MAY 29, 2013$]\n"
                 "THIS WEEK:\n"
                 "THIS MONTH:\n"
                 "THIS QUARTER:\n"
                 "THIS YEAR:\n"
                 "[o] do later [$JULY 12, 2014$]\n"
                 "SOMEDAY:\n")
     assert tasklist.file.getvalue() == expected
コード例 #16
0
 def test_canonical_year_due_on_first_day(self, tasklist):
     tomorrow = datetime.date(2014, 1, 1)
     original = self._canonical_tasklist()
     tasklist.file = make_file(original)
     tasklist.advance(tomorrow)
     expected = ("TOMORROW:\n"
                 "[o] do tomorrow [$FEBRUARY 12, 2013$]\n"
                 "[o] do next week [$WEEK OF FEBRUARY 17, 2013$]\n"
                 "[o] do next month [$MARCH 2013$]\n"
                 "[o] do next quarter [$Q2 2013$]\n"
                 "[o] do next year [$2014$]\n"
                 "THIS WEEK:\n"
                 "THIS MONTH:\n"
                 "THIS QUARTER:\n"
                 "THIS YEAR:\n"
                 "SOMEDAY:\n"
                 "[o] do later [$2015$]\n")
     assert tasklist.file.getvalue() == expected
コード例 #17
0
 def test_task(self, logfile):
     for _ in range(2):
         logfile.readline()
     file = make_file(logfile.read())
     entry, _ = read_entry(file)
     assert entry == "[\\] a WIP task\n"
コード例 #18
0
 def test_blank_line(self, logfile):
     for _ in range(4):
         logfile.readline()
     file = make_file(logfile.read())
     entry, _ = read_entry(file)
     assert entry == "\n"
コード例 #19
0
 def test_text_entry(self, logfile):
     for _ in range(3):
         logfile.readline()
     file = make_file(logfile.read())
     entry, _ = read_entry(file)
     assert entry == "Just some additional clarifications\n"