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


Python TodoList.add方法代码示例

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


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

示例1: test_todo_by_dep_id

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import add [as 别名]
    def test_todo_by_dep_id(self):
        """ Tests that todos can be retrieved by their id tag. """
        todolist = TodoList([])
        todolist.add("(C) Foo id:1")

        self.assertTrue(todolist.todo_by_dep_id("1"))
        self.assertFalse(todolist.todo_by_dep_id("2"))
开发者ID:netimen,项目名称:topydo,代码行数:9,代码来源:TodoListTest.py

示例2: TodoListCleanDependencyTester

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import add [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

示例3: TodoListDependencyTester

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import add [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

示例4: TodoListCleanDependencyTester

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import add [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

示例5: TodoListDependencyTester

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import add [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

示例6: AppendCommandTest

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import add [as 别名]
class AppendCommandTest(CommandTest):
    def setUp(self):
        super().setUp()
        self.todolist = TodoList([])
        self.todolist.add("Foo")
        self.today = date.today().isoformat()

    def test_append1(self):
        command = AppendCommand([1, "Bar"], self.todolist, self.out,
                                self.error)
        command.execute()

        self.assertEqual(self.output, "|  1| Foo Bar\n")
        self.assertEqual(self.errors, "")

    def test_append2(self):
        command = AppendCommand([2, "Bar"], self.todolist, self.out,
                                self.error)
        command.execute()

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

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

        self.assertEqual(self.output, "")
        self.assertEqual(self.output, "")

    def test_append4(self):
        command = AppendCommand([1], self.todolist, self.out, self.error)
        command.execute()

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

    def test_append5(self):
        command = AppendCommand([1, "Bar", "Baz"], self.todolist, self.out,
                                self.error)
        command.execute()

        self.assertEqual(self.output, "|  1| Foo Bar Baz\n")
        self.assertEqual(self.errors, "")

    def test_append6(self):
        command = AppendCommand([], self.todolist, self.out, self.error)
        command.execute()

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

    def test_append7(self):
        command = AppendCommand(["Bar"], self.todolist, self.out, self.error)
        command.execute()

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

    def test_append8(self):
        command = AppendCommand([1, "due:today t:today"], self.todolist,
                                self.out, self.error)
        command.execute()

        self.assertEqual(self.output,
                         "|  1| Foo due:%s t:%s\n" % (self.today, self.today))
        self.assertEqual(self.errors, "")

    def test_append9(self):
        self.todolist.add("Qux due:2015-12-21 t:2015-12-21 before:1")
        self.todolist.add("Baz")
        command = AppendCommand([2, "due:today t:today before:3"], self.todolist,
                                self.out, self.error)
        command.execute()

        self.assertEqual(
                self.output,
                "|  2| Qux due:%s t:%s p:1 p:2\n" % (self.today, self.today))
        self.assertEqual(self.errors, "")

    def test_help(self):
        command = AppendCommand(["help"], self.todolist, self.out, self.error)
        command.execute()

        self.assertEqual(self.output, "")
        self.assertEqual(self.errors,
                         command.usage() + "\n\n" + command.help() + "\n")
开发者ID:MinchinWeb,项目名称:topydo,代码行数:89,代码来源:test_append_command.py

示例7: AppendCommandTest

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import add [as 别名]
class AppendCommandTest(CommandTest):
    def setUp(self):
        super(AppendCommandTest, self).setUp()
        self.todolist = TodoList([])
        self.todolist.add("Foo")

    def test_append1(self):
        command = AppendCommand([1, "Bar"], self.todolist, self.out, self.error)
        command.execute()

        self.assertEqual(self.output, "|  1| Foo Bar\n")
        self.assertEqual(self.errors, "")

    def test_append2(self):
        command = AppendCommand([2, "Bar"], self.todolist, self.out, self.error)
        command.execute()

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

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

        self.assertEqual(self.output, "")
        self.assertEqual(self.output, "")

    def test_append4(self):
        command = AppendCommand([1], self.todolist, self.out, self.error)
        command.execute()

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

    def test_append5(self):
        command = AppendCommand([1, "Bar", "Baz"], self.todolist, self.out, self.error)
        command.execute()

        self.assertEqual(self.output, "|  1| Foo Bar Baz\n")
        self.assertEqual(self.errors, "")

    def test_append6(self):
        command = AppendCommand([], self.todolist, self.out, self.error)
        command.execute()

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

    def test_append7(self):
        command = AppendCommand(["Bar"], self.todolist, self.out, self.error)
        command.execute()

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

    def test_help(self):
        command = AppendCommand(["help"], self.todolist, self.out, self.error)
        command.execute()

        self.assertEqual(self.output, "")
        self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
开发者ID:netimen,项目名称:topydo,代码行数:63,代码来源:AppendCommandTest.py


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