def test_append(self): todo.addm_todo("\n".join(self._test_lines_no_pri(self.num))) for i in range(1, self.num + 1): todo.append_todo([str(i), "testing", "append"]) self.assertNumLines(self.num, "Test\s\d+\stesting\sappend")
def test_del(self): todo.addm_todo("\n".join(self._test_lines_no_pri(self.num))) ran = random.Random() for i in range(self.num, 0, -1): j = ran.randint(1, i) todo.delete_todo(str(j)) self.assertNumLines(0)
def test_deprioritize(self): todo.addm_todo("\n".join(self._test_lines_pri(self.num))) for i in range(0, self.num): todo.de_prioritize_todo(str(i + 1)) self.assertNumLines(self.num, "Test\s\d+") for i in range(0, self.num): todo.de_prioritize_todo(str(i + 1)) self.assertNumLines(self.num, "Test\s\d+")
def test_prioritize(self): todo.addm_todo("\n".join(self._test_lines_no_pri(self.num))) n = len(todo.PRIORITIES) for i in range(0, self.num): todo.prioritize_todo([str(i + 1), todo.PRIORITIES[i % n]]) self.assertNumLines(self.num, "\([A-X]\)\sTest\s\d+") for i in range(0, self.num): todo.prioritize_todo([str(i + 1), todo.PRIORITIES[-i % n]]) self.assertNumLines(self.num, "\([A-X]\)\sTest\s\d+") for i in range(0, self.num): todo.de_prioritize_todo(str(i + 1)) self.assertNumLines(0, "\([A-X]\)\sTest\s\d+") for i in range(0, self.num): todo.prioritize_todo([str(i + 1), todo.PRIORITIES[-i % n]]) self.assertNumLines(self.num, "\([A-X]\)\sTest\s\d+")
def addm_todo_with_pri(self, n): todo.addm_todo("\n".join(self._test_lines_pri(n)))
def test_project(self): todo.addm_todo("\n".join(self._test_lines_project(self.num))) colored, sorted = todo._list_("project", "\+(\w+)") self.assert_not_equal(colored, sorted) self.assert_labeled(colored, sorted)
def test_context(self): todo.addm_todo("\n".join(self._test_lines_context(self.num))) colored, sorted = todo._list_("context", "@(\w+)") self.assert_not_equal(colored, sorted) self.assert_labeled(colored, sorted)
def test_dated(self): todo.addm_todo("\n".join(self._test_lines_date(self.num))) colored, sorted = todo._list_("date", "#\{(\d{4})-(\d{1,2})-(\d{1,2})\}") self.assert_not_equal(colored, sorted) self.assert_dated(colored, sorted)
def addm_todo(self, n): todo.addm_todo("\n".join(self._test_lines_no_pri(n)))