當前位置: 首頁>>代碼示例>>Python>>正文


Python EditCommand.EditCommand類代碼示例

本文整理匯總了Python中topydo.commands.EditCommand.EditCommand的典型用法代碼示例。如果您正苦於以下問題:Python EditCommand類的具體用法?Python EditCommand怎麽用?Python EditCommand使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了EditCommand類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_edit6

    def test_edit6(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.is_dirty())
        self.assertEqual(self.errors, u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
開發者ID:netimen,項目名稱:topydo,代碼行數:7,代碼來源:EditCommandTest.py

示例2: test_edit4

    def test_edit4(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.is_dirty())
        self.assertEqual(self.errors, "Invalid todo number given: 5.\n")
開發者ID:netimen,項目名稱:topydo,代碼行數:7,代碼來源:EditCommandTest.py

示例3: test_edit3

    def test_edit3(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.is_dirty())
        self.assertEqual(self.errors, "Invalid todo number given.\n")
開發者ID:netimen,項目名稱:topydo,代碼行數:7,代碼來源:EditCommandTest.py

示例4: test_help

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

        self.assertEqual(self.output, "")
        self.assertEqual(self.errors,
                         command.usage() + "\n\n" + command.help() + "\n")
開發者ID:bram85,項目名稱:topydo,代碼行數:8,代碼來源:test_edit_command.py

示例5: test_edit_editor6

    def test_edit_editor6(self, mock_call):
        """ Ultimate fallback is vi """
        mock_call.return_value = 0

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

        self.assertEqual(self.errors, "")
        mock_call.assert_called_once_with(['vi', config().todotxt()])
開發者ID:bram85,項目名稱:topydo,代碼行數:9,代碼來源:test_edit_command.py

示例6: test_edit_editor3

    def test_edit_editor3(self, mock_call):
        """ Editor on commandline overrides $TOPYDO_EDITOR """
        mock_call.return_value = 0

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

        self.assertEqual(self.errors, "")
        mock_call.assert_called_once_with(['foo', config().todotxt()])
開發者ID:bram85,項目名稱:topydo,代碼行數:9,代碼來源:test_edit_command.py

示例7: test_edit1

    def test_edit1(self, mock_open_in_editor):
        """ Preserve dependencies after editing. """
        mock_open_in_editor.return_value = 0

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

        self.assertTrue(self.todolist.is_dirty())
        self.assertEqual(self.errors, "")
        self.assertEqual(self.todolist.print_todos(), u("Bar p:1 @test\nBaz @test\nFo\u00f3B\u0105\u017a\nFoo id:1"))
開發者ID:netimen,項目名稱:topydo,代碼行數:10,代碼來源:EditCommandTest.py

示例8: test_edit_editor2

    def test_edit_editor2(self, mock_call):
        """ $TOPYDO_EDITOR overrides $EDITOR """
        mock_call.return_value = 0

        todotxt = config().todotxt()

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

        self.assertEqual(self.errors, "")
        mock_call.assert_called_once_with(['nano', todotxt])
開發者ID:bram85,項目名稱:topydo,代碼行數:11,代碼來源:test_edit_command.py

示例9: test_edit_editor5

    def test_edit_editor5(self, mock_call):
        """ Editor in configuration file overrides $EDITOR """
        mock_call.return_value = 0

        config(p_overrides={('edit', 'editor'): 'foo'})

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

        self.assertEqual(self.errors, "")
        mock_call.assert_called_once_with(['foo', config().todotxt()])
開發者ID:bram85,項目名稱:topydo,代碼行數:11,代碼來源:test_edit_command.py

示例10: test_edit5

    def test_edit5(self, mock_open_in_editor, mock_todos_from_temp):
        """ Don't let to delete todos acidentally while editing. """
        mock_open_in_editor.return_value = 0
        mock_todos_from_temp.return_value = [Todo("Only one line")]

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

        self.assertFalse(self.todolist.is_dirty())
        self.assertEqual(self.errors, "Number of edited todos is not equal to number of supplied todo IDs.\n")
        self.assertEqual(self.todolist.print_todos(), u("Foo id:1\nBar p:1 @test\nBaz @test\nFo\u00f3B\u0105\u017a"))
開發者ID:netimen,項目名稱:topydo,代碼行數:11,代碼來源:EditCommandTest.py

示例11: test_edit2

    def test_edit2(self, mock_open_in_editor, mock_todos_from_temp):
        """ Edit some todo. """
        mock_open_in_editor.return_value = 0
        mock_todos_from_temp.return_value = [Todo("Lazy Cat")]

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

        self.assertTrue(self.todolist.is_dirty())
        self.assertEqual(self.errors, "")
        self.assertEqual(self.todolist.print_todos(), u("Foo id:1\nBaz @test\nFo\u00f3B\u0105\u017a\nLazy Cat"))
開發者ID:netimen,項目名稱:topydo,代碼行數:11,代碼來源:EditCommandTest.py

示例12: test_edit7

    def test_edit7(self, mock_open_in_editor, mock_todos_from_temp):
        """ Edit todo with special characters. """
        mock_open_in_editor.return_value = 0
        mock_todos_from_temp.return_value = [Todo("Lazy Cat")]

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

        self.assertTrue(self.todolist.is_dirty())
        self.assertEqual(self.errors, "")
        self.assertEqual(self.todolist.print_todos(), u("Foo id:1\nBar p:1 @test\nBaz @test\nLazy Cat"))
開發者ID:netimen,項目名稱:topydo,代碼行數:11,代碼來源:EditCommandTest.py

示例13: test_edit_archive

    def test_edit_archive(self, mock_call):
        """ Edit archive file. """
        mock_call.return_value = 0

        archive = config().archive()

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

        self.assertEqual(self.errors, "")
        mock_call.assert_called_once_with(['vi', archive])
開發者ID:bram85,項目名稱:topydo,代碼行數:12,代碼來源:test_edit_command.py

示例14: test_edit01

    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")
開發者ID:bram85,項目名稱:topydo,代碼行數:12,代碼來源:test_edit_command.py

示例15: test_edit07

    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')]
        mock_is_edited.return_value = False

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

        self.assertFalse(self.todolist.dirty)
        self.assertEqual(self.errors, "Editing aborted. Nothing to do.\n")
        self.assertEqual(self.todolist.print_todos(), u"Foo id:1\nBar p:1 @test\nBaz @test\nFo\u00f3B\u0105\u017a")
開發者ID:bram85,項目名稱:topydo,代碼行數:13,代碼來源:test_edit_command.py


注:本文中的topydo.commands.EditCommand.EditCommand類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。