当前位置: 首页>>代码示例>>Python>>正文


Python TodoList.todo方法代码示例

本文整理汇总了Python中topydo.lib.TodoList.TodoList.todo方法的典型用法代码示例。如果您正苦于以下问题:Python TodoList.todo方法的具体用法?Python TodoList.todo怎么用?Python TodoList.todo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在topydo.lib.TodoList.TodoList的用法示例。


在下文中一共展示了TodoList.todo方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TodoListCleanDependencyTester

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import todo [as 别名]
class TodoListCleanDependencyTester(TopydoTest):
    def setUp(self):
        super(TodoListCleanDependencyTester, self).setUp()

        self.todolist = TodoList([])
        self.todolist.add("Bar p:1")
        self.todolist.add("Baz p:1 id:2")
        self.todolist.add("Buzz p:2")

    def test_clean_dependencies(self):
        self.todolist.clean_dependencies()

        self.assertFalse(self.todolist.todo(1).has_tag("p"))
        self.assertFalse(self.todolist.todo(2).has_tag("p"))
        self.assertTrue(self.todolist.todo(2).has_tag("id", "2"))
        self.assertTrue(self.todolist.todo(3).has_tag("p", "2"))
开发者ID:netimen,项目名称:topydo,代码行数:18,代码来源:TodoListTest.py

示例2: test_progress30

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import todo [as 别名]
    def test_progress30(self):
        """ Progress color determined by parent """
        todolist = TodoList([
            "Foo id:1",
            "Bar p:1",
        ])

        color = progress_color(todolist.todo(2))

        # the parent has no influence here
        self.assertEqual(color.color, 2)
开发者ID:MinchinWeb,项目名称:topydo,代码行数:13,代码来源:test_progress_color.py

示例3: test_progress29

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import todo [as 别名]
    def test_progress29(self):
        """ Progress color determined by parent """
        todolist = TodoList([
            "Overdue id:1 due:2015-12-31",
            "Bar p:1 t:2016-01-01 due:2016-01-01",
        ])

        color = progress_color(todolist.todo(2))

        # the parent has no influence here
        self.assertEqual(color.color, 3)
开发者ID:MinchinWeb,项目名称:topydo,代码行数:13,代码来源:test_progress_color.py

示例4: test_progress28

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import todo [as 别名]
    def test_progress28(self):
        """ Progress color determined by parent """
        todolist = TodoList([
            "Overdue id:1 due:2015-12-31",
            "Bar p:1",
        ])

        color = progress_color(todolist.todo(2))

        # color the subitem red because it has no color of its own and its
        # parent is overdue
        self.assertEqual(color.color, 1)
开发者ID:MinchinWeb,项目名称:topydo,代码行数:14,代码来源:test_progress_color.py

示例5: TodoListCleanDependencyTester

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import todo [as 别名]
class TodoListCleanDependencyTester(TopydoTest):
    """
    Tests for cleaning up the graph:

    * Transitive reduction
    * Remove obsolete id: tags
    * Remove obsolete p: tags
    """

    def setUp(self):
        super().setUp()
        self.todolist = TodoList([])

    def test_clean_dependencies1(self):
        """ Clean p: tags from non-existing parent items. """
        self.todolist.add("Bar p:1")
        self.todolist.add("Baz p:1 id:2")
        self.todolist.add("Buzz p:2")

        self.todolist.clean_dependencies()

        self.assertFalse(self.todolist.todo(1).has_tag('p'))
        self.assertFalse(self.todolist.todo(2).has_tag('p'))
        self.assertTrue(self.todolist.todo(2).has_tag('id', '2'))
        self.assertTrue(self.todolist.todo(3).has_tag('p', '2'))

    def test_clean_dependencies2(self):
        """ Clean p: items when siblings are still connected to parent. """
        self.todolist.add("Foo id:1")
        self.todolist.add("Bar p:1")
        self.todolist.add("Baz p:1 id:2")
        self.todolist.add("Buzz p:1 p:2")

        self.todolist.clean_dependencies()

        self.assertFalse(self.todolist.todo(4).has_tag('p', '1'))
        self.assertTrue(self.todolist.todo(1).has_tag('id', '1'))
        self.assertTrue(self.todolist.todo(2).has_tag('p', '1'))

    def test_clean_dependencies3(self):
        """ Clean id: tags from todo items without child todos. """
        self.todolist.add("Foo id:1")

        self.todolist.clean_dependencies()

        self.assertFalse(self.todolist.todo(1).has_tag('id'))
        self.assertFalse(self.todolist.todo_by_dep_id('1'))
开发者ID:rameshg87,项目名称:topydo,代码行数:49,代码来源:test_todo_list.py

示例6: TodoListDependencyTester

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import todo [as 别名]
class TodoListDependencyTester(TopydoTest):
    def setUp(self):
        super(TodoListDependencyTester, self).setUp()

        self.todolist = TodoList([])
        self.todolist.add("Foo id:1")
        self.todolist.add("Bar p:1")
        self.todolist.add("Baz p:1 id:2")
        self.todolist.add("Buzz p:2")
        self.todolist.add("Fnord")
        self.todolist.add("Something with +Project")
        self.todolist.add("Another one with +Project")
        self.todolist.add("Todo with +AnotherProject")
        self.todolist.add("Todo without children id:3")

    def test_check_dep(self):
        children = self.todolist.children(self.todolist.todo(1))
        self.assertEqual(sorted([todo.source() for todo in children]), sorted(["Bar p:1", "Baz p:1 id:2", "Buzz p:2"]))

        children = self.todolist.children(self.todolist.todo(1), True)
        self.assertEqual(sorted([todo.source() for todo in children]), sorted(["Bar p:1", "Baz p:1 id:2"]))

        children = self.todolist.children(self.todolist.todo(3))
        self.assertEqual(sorted([todo.source() for todo in children]), ["Buzz p:2"])

        parents = self.todolist.parents(self.todolist.todo(4))
        self.assertEqual(sorted([todo.source() for todo in parents]), sorted(["Foo id:1", "Baz p:1 id:2"]))

        parents = self.todolist.parents(self.todolist.todo(4), True)
        self.assertEqual(sorted([todo.source() for todo in parents]), ["Baz p:1 id:2"])

        self.assertEqual(self.todolist.children(self.todolist.todo(2)), [])
        self.assertEqual(self.todolist.parents(self.todolist.todo(1)), [])

    def test_add_dep1(self):
        todo4 = self.todolist.todo(4)
        todo5 = self.todolist.todo(5)
        self.todolist.add_dependency(todo5, todo4)

        self.assertTrue(todo5.has_tag("id", "4"))
        self.assertTrue(todo4.has_tag("p", "4"))

    def test_add_dep2(self):
        """
        Make sure that previous add_dependency invocation stored the
        edge_id properly.
        """

        todo1 = self.todolist.todo(1)
        todo4 = self.todolist.todo(4)
        todo5 = self.todolist.todo(5)

        self.todolist.add_dependency(todo5, todo4)
        self.todolist.add_dependency(todo4, todo1)

        self.assertTrue(todo4.has_tag("id", "5"))
        self.assertTrue(todo1.has_tag("p", "5"))

    def test_add_dep3(self):
        """
        Test that projects are not added double.
        """

        todo6 = self.todolist.todo(6)
        todo7 = self.todolist.todo(7)
        projects = todo7.projects().copy()

        self.todolist.add_dependency(todo6, todo7)

        self.assertEqual(projects, todo7.projects())

    def test_add_dep4(self):
        """
        Test that a new project is added to the sub todo.
        """
        config("test/data/config3")

        todo6 = self.todolist.todo(6)
        todo8 = self.todolist.todo(8)

        self.todolist.add_dependency(todo6, todo8)

        self.assertEqual(set(["Project", "AnotherProject"]), todo8.projects())

    def test_remove_dep1(self):
        from_todo = self.todolist.todo(3)
        to_todo = self.todolist.todo(4)
        self.todolist.remove_dependency(from_todo, to_todo)

        self.assertFalse(from_todo.has_tag("id"))
        self.assertFalse(to_todo.has_tag("p"))

    def test_remove_dep2(self):
        old = str(self.todolist)
        from_todo = self.todolist.todo(1)
        to_todo = self.todolist.todo(4)
        self.todolist.remove_dependency(from_todo, to_todo)

        self.assertEqual(str(self.todolist), old)

#.........这里部分代码省略.........
开发者ID:netimen,项目名称:topydo,代码行数:103,代码来源:TodoListTest.py

示例7: DepCommandTest

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import todo [as 别名]
class DepCommandTest(CommandTest):
    def setUp(self):
        super().setUp()
        todos = [
            "Foo id:1",
            "Bar p:1",
            "Baz p:1",
            "Fnord id:2",
            "Garbage dependency p:99",
            "Fart p:2",
        ]

        self.todolist = TodoList(todos)

    def test_add1(self):
        command = DepCommand(["add", "1", "to", "4"], self.todolist, self.out,
                             self.error)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertTrue(self.todolist.todo(4).has_tag('p', '1'))
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "")

    def test_add2(self):
        command = DepCommand(["add", "1", "4"], self.todolist, self.out,
                             self.error)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertTrue(self.todolist.todo(4).has_tag('p', '1'))
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "")

    def test_add3(self):
        command = DepCommand(["add", "99", "3"], self.todolist, self.out,
                             self.error)
        command.execute()

        self.assertFalse(self.todolist.is_dirty())
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "Invalid todo number given.\n")

    def test_add4(self):
        command = DepCommand(["add", "A", "3"], self.todolist, self.out,
                             self.error)
        command.execute()

        self.assertFalse(self.todolist.is_dirty())
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "Invalid todo number given.\n")

    def test_add5(self):
        command = DepCommand(["add", "1"], self.todolist, self.out, self.error)
        command.execute()

        self.assertFalse(self.todolist.is_dirty())
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, command.usage() + "\n")

    def test_add6(self):
        command = DepCommand(["add", "1", "after", "4"], self.todolist,
                             self.out, self.error)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertTrue(self.todolist.todo(4).has_tag('p', '1'))
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "")

    def test_add7(self):
        command = DepCommand(["add", "1", "before", "4"], self.todolist,
                             self.out, self.error)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertTrue(self.todolist.todo(1).has_tag('p', '2'))
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "")

    def test_add8(self):
        command = DepCommand(["add", "1", "partof", "4"], self.todolist,
                             self.out, self.error)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertTrue(self.todolist.todo(1).has_tag('p', '2'))
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "")

    def test_add9(self):
        command = DepCommand(["add", "Foo", "to", "4"], self.todolist,
                             self.out, self.error)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertTrue(self.todolist.todo(4).has_tag('p', '1'))
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "")

#.........这里部分代码省略.........
开发者ID:rameshg87,项目名称:topydo,代码行数:103,代码来源:test_dep_command.py

示例8: DepriCommandTest

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import todo [as 别名]
class DepriCommandTest(CommandTest):
    def setUp(self):
        super().setUp()
        todos = [
            "(A) Foo",
            "Bar",
            "(B) Baz",
            "(E) a @test with due:2015-06-03",
            "(Z) a @test with +project p:1",
            "(D) Bax id:1",
        ]

        self.todolist = TodoList(todos)

    def test_depri1(self):
        command = DepriCommand(["1"], self.todolist, self.out, self.error)
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertEqual(self.todolist.todo(1).priority(), None)
        self.assertEqual(self.output, "Priority removed.\n|  1| Foo\n")
        self.assertEqual(self.errors, "")

    def test_depri2(self):
        command = DepriCommand(["2"], self.todolist, self.out, self.error)
        command.execute()

        self.assertFalse(self.todolist.dirty)
        self.assertEqual(self.todolist.todo(2).priority(), None)
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "")

    def test_depri3(self):
        command = DepriCommand(["Foo"], self.todolist, self.out, self.error)
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertEqual(self.todolist.todo(1).priority(), None)
        self.assertEqual(self.output, "Priority removed.\n|  1| Foo\n")
        self.assertEqual(self.errors, "")

    def test_depri4(self):
        command = DepriCommand(["1", "Baz"], self.todolist, self.out,
                               self.error)
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertEqual(self.todolist.todo(1).priority(), None)
        self.assertEqual(self.todolist.todo(3).priority(), None)
        self.assertEqual(self.output, "Priority removed.\n|  1| Foo\nPriority removed.\n|  3| Baz\n")
        self.assertEqual(self.errors, "")

    def test_expr_depri1(self):
        command = DepriCommand(["-e", "@test"], self.todolist, self.out,
                               self.error, None)
        command.execute()

        result = "Priority removed.\n|  4| a @test with due:2015-06-03\nPriority removed.\n|  5| a @test with +project p:1\n"

        self.assertTrue(self.todolist.dirty)
        self.assertEqual(self.output, result)
        self.assertEqual(self.errors, "")

    def test_expr_depri2(self):
        command = DepriCommand(["-e", "@test", "due:2015-06-03"],
                               self.todolist, self.out, self.error, None)
        command.execute()

        result = "Priority removed.\n|  4| a @test with due:2015-06-03\n"

        self.assertTrue(self.todolist.dirty)
        self.assertEqual(self.output, result)
        self.assertEqual(self.errors, "")

    def test_expr_depri3(self):
        command = DepriCommand(["-e", "@test", "due:2015-06-03", "+project"],
                               self.todolist, self.out, self.error, None)
        command.execute()

        self.assertFalse(self.todolist.dirty)

    def test_expr_depri4(self):
        """ Don't remove priority from unrelevant todo items. """
        command = DepriCommand(["-e", "Bax"], self.todolist, self.out,
                               self.error, None)
        command.execute()

        self.assertFalse(self.todolist.dirty)

    def test_expr_depri5(self):
        """ Force unprioritizing unrelevant items with additional -x flag. """
        command = DepriCommand(["-xe", "Bax"], self.todolist, self.out,
                               self.error, None)
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertEqual(self.output, "Priority removed.\n|  6| Bax id:1\n")
        self.assertEqual(self.errors, "")

    def test_invalid1(self):
#.........这里部分代码省略.........
开发者ID:bram85,项目名称:topydo,代码行数:103,代码来源:test_depri_command.py

示例9: DeleteCommandTest

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import todo [as 别名]
class DeleteCommandTest(CommandTest):
    def setUp(self):
        super().setUp()
        todos = [
            "Foo id:1",
            "Bar p:1",
            "a @test with due:2015-06-03",
            "a @test with +project",
        ]

        self.todolist = TodoList(todos)

    def test_del1(self):
        command = DeleteCommand(["1"], self.todolist, self.out, self.error,
                                _no_prompt)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertEqual(self.todolist.todo(1).source(), "Bar")
        self.assertEqual(self.output, "|  2| Bar p:1\nRemoved: Foo id:1\n")
        self.assertEqual(self.errors, "")

    def test_del1_regex(self):
        command = DeleteCommand(["Foo"], self.todolist, self.out, self.error,
                                _no_prompt)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertEqual(self.todolist.todo(1).source(), "Bar")
        self.assertEqual(self.output, "|  2| Bar p:1\nRemoved: Foo id:1\n")
        self.assertEqual(self.errors, "")

    def test_del2(self):
        command = DeleteCommand(["1"], self.todolist, self.out, self.error,
                                _yes_prompt)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertEqual(self.todolist.count(), 2)
        self.assertEqual(self.output,
                         "|  2| Bar p:1\nRemoved: Bar\nRemoved: Foo\n")
        self.assertEqual(self.errors, "")

    def test_del3(self):
        command = DeleteCommand(["-f", "1"], self.todolist, self.out,
                                self.error, _yes_prompt)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertEqual(self.todolist.count(), 3)  # force won't delete subtasks
        self.assertEqual(self.output, "|  2| Bar p:1\nRemoved: Foo id:1\n")
        self.assertEqual(self.errors, "")

    def test_del4(self):
        command = DeleteCommand(["--force", "1"], self.todolist, self.out,
                                self.error, _yes_prompt)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertEqual(self.todolist.count(), 3)  # force won't delete subtasks
        self.assertEqual(self.output, "|  2| Bar p:1\nRemoved: Foo id:1\n")
        self.assertEqual(self.errors, "")

    def test_del5(self):
        command = DeleteCommand(["2"], self.todolist, self.out, self.error)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertEqual(self.todolist.todo(1).source(), "Foo")
        self.assertEqual(self.output, "Removed: Bar p:1\nThe following todo item(s) became active:\n|  1| Foo\n")
        self.assertEqual(self.errors, "")

    def test_del7(self):
        command = DeleteCommand(["99"], self.todolist, self.out, self.error)
        command.execute()

        self.assertFalse(self.todolist.is_dirty())
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "Invalid todo number given.\n")

    def test_del8(self):
        command = DeleteCommand(["A"], self.todolist, self.out, self.error)
        command.execute()

        self.assertFalse(self.todolist.is_dirty())
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "Invalid todo number given.\n")

    def test_del9(self):
        """ Test deletion with textual IDs. """
        config("test/data/todolist-uid.conf")

        command = DeleteCommand(["8to"], self.todolist, self.out, self.error)
        command.execute()

        result = "Foo\na @test with due:2015-06-03\na @test with +project"

        self.assertEqual(self.todolist.print_todos(), result)
        self.assertRaises(InvalidTodoException, self.todolist.todo, 'b0n')

#.........这里部分代码省略.........
开发者ID:rameshg87,项目名称:topydo,代码行数:103,代码来源:test_delete_command.py

示例10: TagCommandTest

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import todo [as 别名]
class TagCommandTest(CommandTest):
    def setUp(self):
        super().setUp()
        todos = [
            "Foo",
            "Bar due:2014-10-22",
            "Baz due:2014-10-20",
            "Fnord due:2014-10-20 due:2014-10-22",
        ]

        self.todolist = TodoList(todos)

    def test_add_tag1(self):
        command = TagCommand(["1", "due", "2014-10-22"], self.todolist,
                             self.out, self.error)
        command.execute()

        self.assertEqual(self.todolist.todo(1).source(), "Foo due:2014-10-22")
        self.assertEqual(self.output, "|  1| Foo due:2014-10-22\n")
        self.assertEqual(self.errors, "")
        self.assertTrue(self.todolist.dirty)

    def test_add_tag2(self):
        command = TagCommand(["Foo", "due", "2014-10-22"], self.todolist,
                             self.out, self.error)
        command.execute()

        self.assertEqual(self.todolist.todo(1).source(), "Foo due:2014-10-22")
        self.assertEqual(self.output, "|  1| Foo due:2014-10-22\n")
        self.assertEqual(self.errors, "")
        self.assertTrue(self.todolist.dirty)

    def test_add_tag3(self):
        command = TagCommand(["-a", "2", "due", "2014-10-19"], self.todolist,
                             self.out, self.error)
        command.execute()

        self.assertEqual(self.todolist.todo(2).source(),
                         "Bar due:2014-10-22 due:2014-10-19")
        self.assertEqual(self.output,
                         "|  2| Bar due:2014-10-22 due:2014-10-19\n")
        self.assertEqual(self.errors, "")
        self.assertTrue(self.todolist.dirty)

    def test_add_tag4(self):
        command = TagCommand(["Foox", "due", "2014-10-22"], self.todolist,
                             self.out, self.error)
        command.execute()

        self.assertFalse(self.todolist.dirty)
        self.assertFalse(self.output)
        self.assertEqual(self.errors, "Invalid todo number.\n")

    def test_force_add_tag01(self):
        '''Tries to different values to a tag for the same name 3 times.'''
        for letter in ['a', 'b', 'c']:
            command = TagCommand(['-a', '1', 'k', letter], self.todolist,
                                 self.out, self.error)
            command.execute()

            self.assertEqual(self.errors, "")
            self.assertTrue(self.todolist.dirty)
        self.assertEqual(self.todolist.todo(1).source(), "Foo k:a k:b k:c")

    def test_set_tag04(self):
        command = TagCommand(["3", "due", "2014-10-20"], self.todolist,
                             self.out, self.error)
        command.execute()

        self.assertFalse(self.todolist.dirty)
        self.assertEqual(self.output, "|  3| Baz due:2014-10-20\n")
        self.assertEqual(self.errors, "")

    def test_set_tag05(self):
        command = TagCommand(["4", "due", "2014-10-20"], self.todolist,
                             self.out, self.error, lambda t: "all")
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertEqual(self.output, " 1. 2014-10-20\n 2. 2014-10-22\n|  4| Fnord due:2014-10-20 due:2014-10-20\n")
        self.assertEqual(self.errors, "")

    def test_set_tag06(self):
        command = TagCommand(["4", "due", "2014-10-20"], self.todolist,
                             self.out, self.error, lambda t: "1")
        command.execute()

        self.assertFalse(self.todolist.dirty)
        self.assertEqual(self.output, " 1. 2014-10-20\n 2. 2014-10-22\n|  4| Fnord due:2014-10-20 due:2014-10-22\n")
        self.assertEqual(self.errors, "")

    def test_set_tag07(self):
        command = TagCommand(["4", "due", "2014-10-20"], self.todolist,
                             self.out, self.error, lambda t: "2")
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertEqual(self.output, " 1. 2014-10-20\n 2. 2014-10-22\n|  4| Fnord due:2014-10-20 due:2014-10-20\n")
        self.assertEqual(self.errors, "")

#.........这里部分代码省略.........
开发者ID:MinchinWeb,项目名称:topydo,代码行数:103,代码来源:test_tag_command.py

示例11: TodoListDependencyTester

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import todo [as 别名]
class TodoListDependencyTester(TopydoTest):
    def setUp(self):
        super().setUp()

        self.todolist = TodoList([])
        self.todolist.add("Foo id:1")
        self.todolist.add("Bar p:1")
        self.todolist.add("Baz p:1 id:2")
        self.todolist.add("Buzz p:2")
        self.todolist.add("Fnord")
        self.todolist.add("Something with +Project")
        self.todolist.add("Another one with +Project")
        self.todolist.add("Todo with +AnotherProject")
        self.todolist.add("Todo without children id:3")
        self.todolist.add("Orphan p:4")

    def test_check_dep(self):
        children = self.todolist.children(self.todolist.todo(1))
        self.assertEqual(sorted([todo.source() for todo in children]),
                         sorted(['Bar p:1', 'Baz p:1 id:2', 'Buzz p:2']))

        children = self.todolist.children(self.todolist.todo(1), True)
        self.assertEqual(sorted([todo.source() for todo in children]),
                         sorted(['Bar p:1', 'Baz p:1 id:2']))

        children = self.todolist.children(self.todolist.todo(3))
        self.assertEqual(sorted([todo.source() for todo in children]),
                         ['Buzz p:2'])

        parents = self.todolist.parents(self.todolist.todo(4))
        self.assertEqual(sorted([todo.source() for todo in parents]),
                         sorted(['Foo id:1', 'Baz p:1 id:2']))

        parents = self.todolist.parents(self.todolist.todo(4), True)
        self.assertEqual(sorted([todo.source() for todo in parents]),
                         ['Baz p:1 id:2'])

        self.assertEqual(self.todolist.children(self.todolist.todo(2)), [])
        self.assertEqual(self.todolist.parents(self.todolist.todo(1)), [])

    def test_add_dep1(self):
        todo4 = self.todolist.todo(4)
        todo5 = self.todolist.todo(5)
        self.todolist.add_dependency(todo5, todo4)

        self.assertTrue(todo5.has_tag('id', '5'))
        self.assertTrue(todo4.has_tag('p', '5'))

    def test_add_dep2(self):
        """
        Make sure that previous add_dependency invocation stored the
        edge_id properly.
        """
        todo1 = self.todolist.todo(1)
        todo4 = self.todolist.todo(4)
        todo5 = self.todolist.todo(5)

        self.todolist.add_dependency(todo5, todo4)
        self.todolist.add_dependency(todo4, todo1)

        self.assertTrue(todo4.has_tag('id', '6'))
        self.assertTrue(todo1.has_tag('p', '6'))

    def test_add_dep3(self):
        """
        Test that projects are not added double.
        """
        todo6 = self.todolist.todo(6)
        todo7 = self.todolist.todo(7)
        projects = todo7.projects().copy()

        self.todolist.add_dependency(todo6, todo7)

        self.assertEqual(projects, todo7.projects())

    def test_add_dep4(self):
        """
        Test that a new project is added to the sub todo.
        """
        config("test/data/config3")

        todo6 = self.todolist.todo(6)
        todo8 = self.todolist.todo(8)

        self.todolist.add_dependency(todo6, todo8)

        self.assertEqual(set(["Project", "AnotherProject"]), todo8.projects())

    def test_remove_dep1(self):
        from_todo = self.todolist.todo(3)
        to_todo = self.todolist.todo(4)
        self.todolist.remove_dependency(from_todo, to_todo)

        self.assertFalse(from_todo.has_tag('id'))
        self.assertFalse(to_todo.has_tag('p'))
        self.assertFalse(self.todolist.todo_by_dep_id('2'))

    def test_remove_dep2(self):
        old = str(self.todolist)
        from_todo = self.todolist.todo(1)
#.........这里部分代码省略.........
开发者ID:rameshg87,项目名称:topydo,代码行数:103,代码来源:test_todo_list.py

示例12: DepCommandTest

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import todo [as 别名]
class DepCommandTest(CommandTest):
    def setUp(self):
        super().setUp()
        todos = [
            "Foo id:1",
            "Bar p:1",
            "Baz p:1",
            "Fnord id:2",
            "Garbage dependency p:99",
            "Fart p:2",
        ]

        self.todolist = TodoList(todos)

    def test_add1(self):
        command = DepCommand(["add", "1", "to", "4"], self.todolist, self.out,
                             self.error)
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertTrue(self.todolist.todo(4).has_tag('p', '1'))
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "")

    def test_add2(self):
        command = DepCommand(["add", "1", "4"], self.todolist, self.out,
                             self.error)
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertTrue(self.todolist.todo(4).has_tag('p', '1'))
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "")

    def test_add3(self):
        command = DepCommand(["add", "99", "3"], self.todolist, self.out,
                             self.error)
        command.execute()

        self.assertFalse(self.todolist.dirty)
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "Invalid todo number given.\n")

    def test_add4(self):
        command = DepCommand(["add", "A", "3"], self.todolist, self.out,
                             self.error)
        command.execute()

        self.assertFalse(self.todolist.dirty)
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "Invalid todo number given.\n")

    def test_add5(self):
        command = DepCommand(["add", "1"], self.todolist, self.out, self.error)
        command.execute()

        self.assertFalse(self.todolist.dirty)
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, command.usage() + "\n")

    def test_add6(self):
        command = DepCommand(["add", "1", "after", "4"], self.todolist,
                             self.out, self.error)
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertTrue(self.todolist.todo(4).has_tag('p', '1'))
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "")

    def test_add7(self):
        command = DepCommand(["add", "1", "before", "4"], self.todolist,
                             self.out, self.error)
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertTrue(self.todolist.todo(1).has_tag('p', '2'))
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "")

    def test_add8(self):
        command = DepCommand(["add", "1", "partof", "4"], self.todolist,
                             self.out, self.error)
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertTrue(self.todolist.todo(1).has_tag('p', '2'))
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "")

    def test_add9(self):
        command = DepCommand(["add", "Foo", "to", "4"], self.todolist,
                             self.out, self.error)
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertTrue(self.todolist.todo(4).has_tag('p', '1'))
        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, "")

#.........这里部分代码省略.........
开发者ID:bram85,项目名称:topydo,代码行数:103,代码来源:test_dep_command.py

示例13: DoCommandTest

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import todo [as 别名]
class DoCommandTest(CommandTest):
    def setUp(self):
        super().setUp()
        todos = [
            "Foo id:1",
            "Bar p:1",
            "Baz p:1",
            "Recurring! rec:1d",
            "x 2014-10-18 Already complete",
            "Inactive t:2030-12-31 id:2",
            "Subtodo of inactive p:2",
            "Strict due:2014-01-01 rec:1d",
            "Invalid rec:1",
            "a @test with due:2015-06-03",
            "a @test with +project",
        ]

        self.todolist = TodoList(todos)
        self.today = date.today()
        self.tomorrow = self.today + timedelta(1)
        self.yesterday = self.today - timedelta(1)

        self.yesterday = self.yesterday.isoformat()
        self.today = self.today.isoformat()
        self.tomorrow = self.tomorrow.isoformat()

    def test_do1(self):
        command = DoCommand(["3"], self.todolist, self.out, self.error,
                            _no_prompt)
        command.execute()
        command.execute_post_archive_actions()

        self.assertTrue(self.todolist.dirty)
        self.assertTrue(self.todolist.todo(3).is_completed())
        self.assertEqual(self.output,
                         "Completed: x {} Baz p:1\n".format(self.today))
        self.assertEqual(self.errors, "")

    def test_do_subtasks1(self):
        command = DoCommand(["1"], self.todolist, self.out, self.error,
                            _yes_prompt)
        command.execute()
        command.execute_post_archive_actions()

        result = "|  2| Bar p:1\n|  3| Baz p:1\nCompleted: x {today} Bar p:1\nCompleted: x {today} Baz p:1\nCompleted: x {today} Foo id:1\n".format(today=self.today)

        for number in [1, 2, 3]:
            self.assertTrue(self.todolist.todo(number).is_completed())

        self.assertTrue(self.todolist.dirty)
        self.assertFalse(self.todolist.todo(4).is_completed())
        self.assertEqual(self.output, result)
        self.assertEqual(self.errors, "")

    def test_do_subtasks2(self):
        command = DoCommand(["1"], self.todolist, self.out, self.error,
                            _no_prompt)
        command.execute()
        command.execute_post_archive_actions()

        result = "|  2| Bar p:1\n|  3| Baz p:1\nCompleted: x {} Foo id:1\n".format(self.today)

        self.assertTrue(self.todolist.dirty)
        self.assertTrue(self.todolist.todo(1).is_completed())
        self.assertFalse(self.todolist.todo(2).is_completed())
        self.assertFalse(self.todolist.todo(3).is_completed())
        self.assertEqual(self.output, result)
        self.assertEqual(self.errors, "")

    def test_do_subtasks_force1(self):
        prompt_shown = False

        def prompt(p_prompt):
            global prompt_shown
            prompt_shown = True

        command = DoCommand(["-f", "1"], self.todolist, self.out, self.error,
                            prompt)
        command.execute()
        command.execute_post_archive_actions()

        self.assertFalse(prompt_shown)
        self.assertEqual(self.errors, "")
        self.assertFalse(self.todolist.todo(2).is_completed())

    def test_do_subtasks_force2(self):
        prompt_shown = False

        def prompt(p_prompt):
            global prompt_shown
            prompt_shown = True

        command = DoCommand(["--force", "1"], self.todolist, self.out,
                            self.error, prompt)
        command.execute()
        command.execute_post_archive_actions()

        self.assertFalse(prompt_shown)
        self.assertEqual(self.errors, "")
        self.assertFalse(self.todolist.todo(2).is_completed())
#.........这里部分代码省略.........
开发者ID:rcraggs,项目名称:topydo,代码行数:103,代码来源:test_do_command.py


注:本文中的topydo.lib.TodoList.TodoList.todo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。