本文整理汇总了Python中topydo.lib.TodoList.TodoList.remove_dependency方法的典型用法代码示例。如果您正苦于以下问题:Python TodoList.remove_dependency方法的具体用法?Python TodoList.remove_dependency怎么用?Python TodoList.remove_dependency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类topydo.lib.TodoList.TodoList
的用法示例。
在下文中一共展示了TodoList.remove_dependency方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TodoListDependencyTester
# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import remove_dependency [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)
#.........这里部分代码省略.........
示例2: TodoListDependencyTester
# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import remove_dependency [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)
#.........这里部分代码省略.........