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


Python TodoList.delete方法代码示例

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


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

示例1: TodoListDependencyTester

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import delete [as 别名]

#.........这里部分代码省略.........
        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)

    def test_remove_todo_check_children(self):
        todo = self.todolist.todo(2)
        self.todolist.delete(todo)

        todo = self.todolist.todo(2)
        self.assertTrue(self.todolist.children(todo))

    def test_remove_task(self):
        todo = self.todolist.todo(3)
        self.todolist.delete(todo)
        self.assertFalse(todo.has_tag("p", "2"))

        todo = self.todolist.todo(1)
        children = self.todolist.children(todo)
        self.assertEqual([t.source() for t in children], ["Bar p:1"])

    def test_add_double_dep(self):
        todo1 = self.todolist.todo(1)
        todo2 = self.todolist.todo(2)
        self.todolist.add_dependency(todo1, todo2)

        self.assertEqual(todo1.source(), "Foo id:1")
        self.assertEqual(todo2.source(), "Bar p:1")

    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,代码行数:104,代码来源:TodoListTest.py

示例2: TodoListDependencyTester

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import delete [as 别名]

#.........这里部分代码省略.........
        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)
        to_todo = self.todolist.todo(4)
        self.todolist.remove_dependency(from_todo, to_todo)

        self.assertEqual(str(self.todolist), old)
        self.assertTrue(self.todolist.todo_by_dep_id('1'))
        self.assertTrue(self.todolist.todo_by_dep_id('2'))
        self.assertTrue(self.todolist.todo_by_dep_id('3'))

    def test_remove_dep3(self):
        """ Try to remove non-existing dependency. """
        old = str(self.todolist)
        from_todo = self.todolist.todo(4)
        to_todo = self.todolist.todo(1)
        self.todolist.remove_dependency(from_todo, to_todo)

        self.assertEqual(str(self.todolist), old)
        self.assertTrue(self.todolist.todo_by_dep_id('1'))
        self.assertTrue(self.todolist.todo_by_dep_id('2'))
        self.assertTrue(self.todolist.todo_by_dep_id('3'))

    def test_remove_todo_check_children(self):
        todo = self.todolist.todo(2)
        self.todolist.delete(todo)

        todo = self.todolist.todo(2)
        self.assertTrue(self.todolist.children(todo))

    def test_remove_task(self):
        todo = self.todolist.todo(3)
        self.todolist.delete(todo)
        self.assertFalse(todo.has_tag('p', '2'))
        self.assertFalse(self.todolist.todo_by_dep_id('2'))

        todo = self.todolist.todo(1)
        children = self.todolist.children(todo)
        self.assertEqual([t.source() for t in children], ['Bar p:1'])

    def test_add_double_dep(self):
        todo1 = self.todolist.todo(1)
        todo2 = self.todolist.todo(2)
        self.todolist.add_dependency(todo1, todo2)

        self.assertEqual(todo1.source(), 'Foo id:1')
        self.assertEqual(todo2.source(), 'Bar p:1')

    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'))

    def test_add_after_dependencies(self):
        """
开发者ID:rameshg87,项目名称:topydo,代码行数:70,代码来源:test_todo_list.py


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