• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python TodoList.TodoList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_todo_by_dep_id

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


示例2: test_view

    def test_view(self):
        """ Check filters and printer for views. """
        todofile = TodoFile('test/data/FilterTest1.txt')
        ref = load_file('test/data/ViewTest1-result.txt')

        todolist = TodoList(todofile.read())
        sorter = Sorter('text')
        todofilter = Filter.GrepFilter('+Project')
        view = todolist.view(sorter, [todofilter])

        self.assertEqual(print_view(view), todolist_to_string(ref))
开发者ID:rameshg87,项目名称:topydo,代码行数:11,代码来源:test_view.py


示例3: test_progress30

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


示例4: test_progress29

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


示例5: test_archive

    def test_archive(self):
        todolist = load_file_to_todolist("test/data/ArchiveCommandTest.txt")
        archive = TodoList([])

        command = ArchiveCommand(todolist, archive)
        command.execute()

        self.assertTrue(todolist.is_dirty())
        self.assertTrue(archive.is_dirty())
        self.assertEqual(todolist.print_todos(), "x Not complete\n(C) Active")
        self.assertEqual(archive.print_todos(), "x 2014-10-19 Complete\nx 2014-10-20 Another one complete")
开发者ID:netimen,项目名称:topydo,代码行数:11,代码来源:ArchiveCommandTest.py


示例6: test_progress28

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


示例7: get_backup

    def get_backup(self, p_todolist):
        """
        Retrieves a backup for p_todolist from backup file and sets todolist,
        archive and call attributes to appropriate data from it.
        """
        change_hash = hash_todolist(p_todolist)

        index = self._get_index()
        self.timestamp = index[[change[1] for change in index].index(change_hash)][0]

        d = self.backup_dict[self.timestamp]

        self.todolist = TodoList(d[0])
        self.archive = TodoList(d[1])
        self.call = d[2]
开发者ID:MinchinWeb,项目名称:topydo,代码行数:15,代码来源:ChangeSet.py


示例8: setUp

    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")
开发者ID:netimen,项目名称:topydo,代码行数:7,代码来源:TodoListTest.py


示例9: setUp

    def setUp(self):
        super().setUp()
        todos = [
            "Foo id:1",
            "Bar p:1 @test",
            "Baz @test",
            u"Fo\u00f3B\u0105\u017a",
        ]

        self.todolist = TodoList(todos)
开发者ID:bram85,项目名称:topydo,代码行数:10,代码来源:test_edit_command.py


示例10: setUp

    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)
开发者ID:MinchinWeb,项目名称:topydo,代码行数:10,代码来源:test_tag_command.py


示例11: setUp

    def setUp(self):
        super(PriorityCommandTest, self).setUp()
        todos = [
            "(A) Foo",
            "Bar",
            "(B) a @test with due:2015-06-03",
            "a @test with +project p:1",
            "Baz id:1",
        ]

        self.todolist = TodoList(todos)
开发者ID:netimen,项目名称:topydo,代码行数:11,代码来源:PriorityCommandTest.py


示例12: setUp

    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)
开发者ID:bram85,项目名称:topydo,代码行数:12,代码来源:test_depri_command.py


示例13: setUp

    def setUp(self):
        super().setUp()
        todos = [
            "Foo",
            "Bar",
            "Baz",
        ]

        self.todolist = TodoList(todos)
        self.today = date.today()

        self.tmp_name = str(uuid4().hex.upper()[0:6])

        archive_filename = tempfile.gettempdir() + os.sep + self.tmp_name + '_archive'
        todo_filename = tempfile.gettempdir() + os.sep + self.tmp_name + '_todo'

        config(p_overrides={('topydo', 'archive_filename'): archive_filename,
            ('topydo', 'filename'): todo_filename, ('topydo', 'backup_count'): '5'})

        self.archive_file = TodoFile(archive_filename)
        self.archive = TodoList([])
开发者ID:rcraggs,项目名称:topydo,代码行数:21,代码来源:test_revert_command.py


示例14: setUp

    def setUp(self):
        super(PostponeCommandTest, self).setUp()
        self.today = date.today()
        self.past = date.today() - timedelta(1)
        self.future = date.today() + timedelta(1)
        self.start = date.today() - timedelta(2)
        self.future_start = self.future - timedelta(2)

        todos = [
            "Foo",
            "Bar due:{}".format(self.today.isoformat()),
            "Baz due:{} t:{}".format(self.today.isoformat(), self.start.isoformat()),
            "Past due:{}".format(self.past.isoformat()),
            "Future due:{} t:{}".format(self.future.isoformat(), self.future_start.isoformat()),
            "FutureStart t:{}".format(self.future.isoformat())
        ]

        self.todolist = TodoList(todos)
开发者ID:netimen,项目名称:topydo,代码行数:18,代码来源:PostponeCommandTest.py


示例15: setUp

    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()
开发者ID:rcraggs,项目名称:topydo,代码行数:24,代码来源:test_do_command.py


示例16: TodoListDependencyTester

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


示例17: TodoListDependencyTester

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


示例18: EditCommandTest

class EditCommandTest(CommandTest):
    def setUp(self):
        super().setUp()
        todos = [
            "Foo id:1",
            "Bar p:1 @test",
            "Baz @test",
            u"Fo\u00f3B\u0105\u017a",
        ]

        self.todolist = TodoList(todos)

    @mock.patch('topydo.commands.EditCommand._is_edited')
    @mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp')
    @mock.patch('topydo.commands.EditCommand.EditCommand._open_in_editor')
    def test_edit01(self, mock_open_in_editor, mock_todos_from_temp, mock_is_edited):
        """ Preserve dependencies after editing. """
        mock_open_in_editor.return_value = 0
        mock_todos_from_temp.return_value = [Todo('Foo id:1')]
        mock_is_edited.return_value = True

        command = EditCommand(["1"], self.todolist, self.out, self.error, None)
        command.execute()

        self.assertEqual(self.errors, "")
        self.assertTrue(self.todolist.dirty)
        self.assertEqual(self.todolist.print_todos(), u"Bar p:1 @test\nBaz @test\nFo\u00f3B\u0105\u017a\nFoo id:1")

    @mock.patch('topydo.commands.EditCommand._is_edited')
    @mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp')
    @mock.patch('topydo.commands.EditCommand.EditCommand._open_in_editor')
    def test_edit02(self, mock_open_in_editor, mock_todos_from_temp, mock_is_edited):
        """ Edit some todo. """
        mock_open_in_editor.return_value = 0
        mock_todos_from_temp.return_value = [Todo('Lazy Cat')]
        mock_is_edited.return_value = True

        command = EditCommand(["Bar"], self.todolist, self.out, self.error,
                              None)
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertEqual(self.errors, "")
        self.assertEqual(self.todolist.print_todos(), u"Foo id:1\nBaz @test\nFo\u00f3B\u0105\u017a\nLazy Cat")

    def test_edit03(self):
        """ Throw an error after invalid todo number given as argument. """
        command = EditCommand(["FooBar"], self.todolist, self.out, self.error,
                              None)
        command.execute()

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

    def test_edit04(self):
        """ Throw an error with pointing invalid argument. """
        command = EditCommand(["Bar", "5"], self.todolist, self.out,
                              self.error, None)
        command.execute()

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

    def test_edit05(self):
        """
        Throw an error with invalid argument containing special characters.
        """
        command = EditCommand([u"Fo\u00d3B\u0105r", "Bar"], self.todolist,
                              self.out, self.error, None)
        command.execute()

        self.assertFalse(self.todolist.dirty)
        self.assertEqual(self.errors,
                         u"Invalid todo number given: Fo\u00d3B\u0105r.\n")

    @mock.patch('topydo.commands.EditCommand._is_edited')
    @mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp')
    @mock.patch('topydo.commands.EditCommand.EditCommand._open_in_editor')
    def test_edit06(self, mock_open_in_editor, mock_todos_from_temp, mock_is_edited):
        """ Edit todo with special characters. """
        mock_open_in_editor.return_value = 0
        mock_todos_from_temp.return_value = [Todo('Lazy Cat')]
        mock_is_edited.return_value = True

        command = EditCommand([u"Fo\u00f3B\u0105\u017a"], self.todolist,
                              self.out, self.error, None)
        command.execute()

        self.assertTrue(self.todolist.dirty)
        self.assertEqual(self.errors, "")
        self.assertEqual(self.todolist.print_todos(),
                         u"Foo id:1\nBar p:1 @test\nBaz @test\nLazy Cat")

    @mock.patch('topydo.commands.EditCommand._is_edited')
    @mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp')
    @mock.patch('topydo.commands.EditCommand.EditCommand._open_in_editor')
    def test_edit07(self, mock_open_in_editor, mock_todos_from_temp, mock_is_edited):
        """ Don't perform write if tempfile is unchanged """
        mock_open_in_editor.return_value = 0
        mock_todos_from_temp.return_value = [Todo('Only one line')]
#.........这里部分代码省略.........
开发者ID:bram85,项目名称:topydo,代码行数:101,代码来源:test_edit_command.py


示例19: DepCommandTest

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


示例20: TagCommandTest

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python torch.abs函数代码示例发布时间:2022-05-27
下一篇:
Python TodoBase.TodoBase类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap