コード例 #1
0
    def test_toggle_checkbox(self):
        set_active_view_text(
            "* Caption\n"
            " - [ ] checkbox\n")

        set_active_view_cursor_position(1, 1)
        self.view.run_command('zorg_toggle_checkbox')
        self.assertEqual(
            get_active_view_text(),
            "* Caption\n"
            " - [ ] checkbox\n")

        set_active_view_cursor_position(2, 1)
        self.view.run_command('zorg_toggle_checkbox')
        self.assertEqual(
            get_active_view_text(),
            "* Caption\n"
            " - [X] checkbox\n")

        set_active_view_cursor_position(2, 1)
        self.view.run_command('zorg_toggle_checkbox')
        self.assertEqual(
            get_active_view_text(),
            "* Caption\n"
            " - [ ] checkbox\n")
コード例 #2
0
    def test_unordinary_cases(self):
        TEST_STRING = (
            "* [ ] Not checkbox but a headline\n"
            " * [ ] This is checkbox\n"
            " + [ ] Also checkbox\n"
            " - [] Not a checkbox\n"
            " 100500. [ ] Checkbox\n"
            " A. [ ] Checkbox\n"
            " -[] Not a checkbox\n"
            " [ ] Not a checkbox\n"
            "- [ ] Checkbox\n"
            "-[ ] Not a checkbox\n")
        set_active_view_text(TEST_STRING)

        for i in range(len(TEST_STRING.strip('\n').split('\n'))):
            set_active_view_cursor_position(i, 1)
            self.view.run_command('zorg_toggle_checkbox')

        self.assertEqual(
            get_active_view_text(),
            "* [ ] Not checkbox but a headline\n"
            " * [X] This is checkbox\n"
            " + [X] Also checkbox\n"
            " - [] Not a checkbox\n"
            " 100500. [X] Checkbox\n"
            " A. [X] Checkbox\n"
            " -[] Not a checkbox\n"
            " [ ] Not a checkbox\n"
            "- [X] Checkbox\n"
            "-[ ] Not a checkbox\n")
コード例 #3
0
ファイル: test_move_node.py プロジェクト: rdpli/Zorgmode
    def test_ordinary_move(self):
        set_active_view_text(
            " - List entry\n"
            " - Other list entry\n")
        set_active_view_cursor_position(1, 1)
        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            " - Other list entry\n"
            " - List entry\n")
        self.assertEqual(get_active_view_cursor_position(), (2, 1))

        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            " - Other list entry\n"
            " - List entry\n")
        self.assertEqual(get_active_view_cursor_position(), (2, 1))

        self.view.run_command('zorg_move_node_up')
        self.assertEqual(
            get_active_view_text(),
            " - List entry\n"
            " - Other list entry\n")
        self.assertEqual(get_active_view_cursor_position(), (1, 1))

        self.view.run_command('zorg_move_node_up')
        self.assertEqual(
            get_active_view_text(),
            " - List entry\n"
            " - Other list entry\n")
        self.assertEqual(get_active_view_cursor_position(), (1, 1))
コード例 #4
0
    def test_unordinary_cases(self):
        TEST_STRING = ("* [ ] Not checkbox but a headline\n"
                       " * [ ] This is checkbox\n"
                       " + [ ] Also checkbox\n"
                       " - [] Not a checkbox\n"
                       " 100500. [ ] Checkbox\n"
                       " A. [ ] Checkbox\n"
                       " -[] Not a checkbox\n"
                       " [ ] Not a checkbox\n"
                       "- [ ] Checkbox\n"
                       "-[ ] Not a checkbox\n")
        set_active_view_text(TEST_STRING)

        for i in range(len(TEST_STRING.strip('\n').split('\n'))):
            set_active_view_cursor_position(i, 1)
            self.view.run_command('zorg_toggle_checkbox')

        self.assertEqual(
            get_active_view_text(), "* [ ] Not checkbox but a headline\n"
            " * [X] This is checkbox\n"
            " + [X] Also checkbox\n"
            " - [] Not a checkbox\n"
            " 100500. [X] Checkbox\n"
            " A. [X] Checkbox\n"
            " -[] Not a checkbox\n"
            " [ ] Not a checkbox\n"
            "- [X] Checkbox\n"
            "-[ ] Not a checkbox\n")
コード例 #5
0
ファイル: test_move_node.py プロジェクト: rdpli/Zorgmode
    def test_edge_of_file(self):
        set_active_view_text(
            "** Caption\n"
            "some text\n"
            "*** Other caption\n"
            "** Caption2\n")

        set_active_view_cursor_position(1, 5)
        self.view.run_command('zorg_move_node_up')
        self.assertEqual(
            get_active_view_text(),
            "** Caption\n"
            "some text\n"
            "*** Other caption\n"
            "** Caption2\n")
        self.assertEqual(get_active_view_cursor_position(), (1, 5))

        set_active_view_cursor_position(4, 2)
        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            "** Caption\n"
            "some text\n"
            "*** Other caption\n"
            "** Caption2\n")
        self.assertEqual(get_active_view_cursor_position(), (4, 2))
コード例 #6
0
    def test_selection(self):
        set_active_view_text("* Caption\n"  # 1
                             " - [ ] checkbox 1\n"  # 2
                             " - [X] checkbox 2\n"  # 3
                             "   - [ ] checkbox 3\n"  # 4
                             " - [] not a checkbox 4\n"  # 5
                             " - [ ] will not be toggled\n"  # 6
                             )

        view = get_active_view()
        sel = view.sel().clear()
        view.sel().add(sublime.Region(0, view.text_point(5, 0)))
        self.view.run_command('zorg_toggle_checkbox')
        self.assertEqual(
            get_active_view_text(), "* Caption\n"
            " - [X] checkbox 1\n"
            " - [X] checkbox 2\n"
            "   - [X] checkbox 3\n"
            " - [] not a checkbox 4\n"
            " - [ ] will not be toggled\n")
        self.view.run_command('zorg_toggle_checkbox')
        self.assertEqual(
            get_active_view_text(), "* Caption\n"
            " - [ ] checkbox 1\n"
            " - [ ] checkbox 2\n"
            "   - [ ] checkbox 3\n"
            " - [] not a checkbox 4\n"
            " - [ ] will not be toggled\n")
コード例 #7
0
ファイル: test_agenda.py プロジェクト: dim-an/zorgmode
    def test_simple_agenda(self):
        original_file_view = get_active_view()
        set_active_view_text(
            "* TODO Write agenda tests\n"  # 1
            "** TODO Open an editor\n"  # 2
            "** TODO Type tests\n"  # 3
            "** TODO Close the editor\n")  # 4
        original_file_view.run_command("zorg_todo_list", {
            "show_in": "new_tab",
            "zorg_agenda_files": ["/dev/sublimetext_view/{}".format(get_active_view().id())],
        })

        agenda_view = get_active_view()
        self.assertEqual(
            get_active_view_text(),
            "#+BEGIN_AGENDA\n"  # 1
            "  TODO:    TODO Write agenda tests\n"  # 3
            "  TODO:    TODO Open an editor\n"  # 4
            "  TODO:    TODO Type tests\n"  # 5
            "  TODO:    TODO Close the editor\n"  # 6
            "#+END_AGENDA\n"  # 7
        )
        set_cursor_position(agenda_view, 4, 1)
        agenda_view.run_command("zorg_agenda_goto")

        self.assertEqual(get_active_view().id(), original_file_view.id())
        self.assertEqual(get_active_view_cursor_position(), (3, 1))
コード例 #8
0
ファイル: test_agenda.py プロジェクト: rdpli/Zorgmode
    def test_simple_agenda(self):
        original_file_view = get_active_view()
        set_active_view_text("* TODO Write agenda tests\n"  # 1
                             "** TODO Open an editor\n"  # 2
                             "** TODO Type tests\n"  # 3
                             "** TODO Close the editor\n")  # 4
        original_file_view.run_command(
            "zorg_todo_list", {
                "show_in":
                "new_tab",
                "zorg_agenda_files":
                ["/dev/sublimetext_view/{}".format(get_active_view().id())],
            })

        agenda_view = get_active_view()
        self.assertEqual(
            get_active_view_text(),
            "#+BEGIN_AGENDA\n"  # 1
            "  TODO:    TODO Write agenda tests\n"  # 3
            "  TODO:    TODO Open an editor\n"  # 4
            "  TODO:    TODO Type tests\n"  # 5
            "  TODO:    TODO Close the editor\n"  # 6
            "#+END_AGENDA\n"  # 7
        )
        set_cursor_position(agenda_view, 4, 1)
        agenda_view.run_command("zorg_agenda_goto")

        self.assertEqual(get_active_view().id(), original_file_view.id())
        self.assertEqual(get_active_view_cursor_position(), (3, 1))
コード例 #9
0
ファイル: test_follow_links.py プロジェクト: rdpli/Zorgmode
 def test_simple_follow_link_header_tags(self):
     set_active_view_text("some text [[Header 2]]\n"
                          #            ^0   ^5   ^10
                          "* Header 1\n"
                          "** Header 2 :some_tag:another_tag:\n")
     set_active_view_cursor_position(1, 12)
     self.view.run_command("zorg_follow_link")
     self.assertEqual(get_active_view_cursor_position(), (3, 1))
コード例 #10
0
ファイル: test_follow_links.py プロジェクト: rdpli/Zorgmode
    def test_link_abbreviations(self):
        set_active_view_text("* Header 1\n"
                             "some text [[hdr:1]]\n"
                             "#+LINK: hdr Header %s\n")
        #    ^0   ^5   ^10

        set_active_view_cursor_position(2, 12)
        self.view.run_command("zorg_follow_link")
        self.assertEqual(get_active_view_cursor_position(), (1, 1))
コード例 #11
0
 def test_cut_section(self):
     set_active_view_text("* Header 1\n"
                          "some text\n"
                          "** Header 2\n"
                          "another text\n"
                          "* Header 3\n")
     set_active_view_cursor_position(1, 1)
     get_active_view().run_command("zorg_cut_node")
     self.assertEqual(get_active_view_text(), "* Header 3\n")
コード例 #12
0
ファイル: test_follow_links.py プロジェクト: rdpli/Zorgmode
 def test_simple_follow_link_everything(self):
     set_active_view_text(
         "some text [[Header 2][link text]]\n"
         #    ^0   ^5   ^10  ^15  ^20
         "* Header 1\n"
         "** TODO [#c]  Header 2  :some_tag:another_tag:  \n")
     set_active_view_cursor_position(1, 22)
     self.view.run_command("zorg_follow_link")
     self.assertEqual(get_active_view_cursor_position(), (3, 1))
コード例 #13
0
ファイル: test_move_node.py プロジェクト: rdpli/Zorgmode
    def test_text(self):
        set_active_view_text(
            " - List entry\n"
            "  1111\n"
            "  * sublst 1 child 1\n"
            "  2222\n"
            "  * sublst 2 child 1\n"
            "  * sublst 2 child 2\n"
            " - Other list entry\n"
            "  * 4444\n"
            "  3333\n"
        )
        set_active_view_cursor_position(3, 1)

        with self.ensure_nothing_changes():
            self.view.run_command('zorg_move_node_up')

        with self.ensure_nothing_changes():
            self.view.run_command('zorg_move_node_down')

        set_active_view_cursor_position(5, 1)
        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            " - List entry\n"
            "  1111\n"
            "  * sublst 1 child 1\n"
            "  2222\n"
            "  * sublst 2 child 2\n"
            "  * sublst 2 child 1\n"
            " - Other list entry\n"
            "  * 4444\n"
            "  3333\n"
        )
        self.assertEqual(get_active_view_cursor_position(), (6, 1))

        with self.ensure_nothing_changes():
            self.view.run_command('zorg_move_node_down')

        self.view.run_command('zorg_move_node_up')
        self.assertEqual(
            get_active_view_text(),
            " - List entry\n"
            "  1111\n"
            "  * sublst 1 child 1\n"
            "  2222\n"
            "  * sublst 2 child 1\n"
            "  * sublst 2 child 2\n"
            " - Other list entry\n"
            "  * 4444\n"
            "  3333\n"
        )
        self.assertEqual(get_active_view_cursor_position(), (5, 1))

        with self.ensure_nothing_changes():
            self.view.run_command('zorg_move_node_up')
コード例 #14
0
 def test_cut_list_entry(self):
     set_active_view_text("  - foo\n"
                          "  - bar\n"
                          "    * baz\n"
                          "     continuation of baz\n"
                          "   continuation of bar\n"
                          " + qux\n")
     set_active_view_cursor_position(2, 1)
     get_active_view().run_command("zorg_cut_node")
     self.assertEqual(get_active_view_text(), "  - foo\n" " + qux\n")
コード例 #15
0
ファイル: test_follow_links.py プロジェクト: rdpli/Zorgmode
    def test_follow_link_jump_back(self):
        set_active_view_text("* Header 1\n" "some text [[Header 1]]\n")
        #    ^0   ^5   ^10

        set_active_view_cursor_position(2, 12)
        self.view.run_command("zorg_follow_link")
        self.assertEqual(get_active_view_cursor_position(), (1, 1))

        self.view.run_command("jump_back")
        self.assertEqual(get_active_view_cursor_position(), (2, 12))
コード例 #16
0
ファイル: test_move_node.py プロジェクト: rdpli/Zorgmode
    def test_sublists(self):
        set_active_view_text(
            " - List entry\n"
            "  * child list entry\n"
            "  * other child list entry\n"
            " - Other list entry\n"
            "  * 333333\n")
        set_active_view_cursor_position(2, 1)

        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            " - List entry\n"
            "  * other child list entry\n"
            "  * child list entry\n"
            " - Other list entry\n"
            "  * 333333\n")
        self.assertEqual(get_active_view_cursor_position(), (3, 1))

        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            " - List entry\n"
            "  * other child list entry\n"
            "  * child list entry\n"
            " - Other list entry\n"
            "  * 333333\n")
        self.assertEqual(get_active_view_cursor_position(), (3, 1))

        self.view.run_command('zorg_move_node_up')
        self.assertEqual(
            get_active_view_text(),
            " - List entry\n"
            "  * child list entry\n"
            "  * other child list entry\n"
            " - Other list entry\n"
            "  * 333333\n")
        self.assertEqual(get_active_view_cursor_position(), (2, 1))

        with self.ensure_nothing_changes():
            self.view.run_command('zorg_move_node_up')

        set_active_view_cursor_position(1, 1)
        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            " - Other list entry\n"
            "  * 333333\n"
            " - List entry\n"
            "  * child list entry\n"
            "  * other child list entry\n")
        self.assertEqual(get_active_view_cursor_position(), (3, 1))

        with self.ensure_nothing_changes():
            self.view.run_command('zorg_move_node_down')
コード例 #17
0
ファイル: test_archivation.py プロジェクト: rdpli/Zorgmode
 def test_archivation_to_nonexistent_file(self):
     set_active_view_text("#+ARCHIVE:/dev/null/nonexistent_file\n"
                          "* Header 1\n"
                          "** Header 2\n"
                          "* Header 3\n")
     set_active_view_cursor_position(3, 2)
     self.view.run_command("zorg_move_to_archive", {"silent": True})
     self.assertEqual(
         get_active_view_text(), "#+ARCHIVE:/dev/null/nonexistent_file\n"
         "* Header 1\n"
         "** Header 2\n"
         "* Header 3\n")
コード例 #18
0
ファイル: test_move_node.py プロジェクト: rdpli/Zorgmode
 def test_cursor_on_boundary(self):
     set_active_view_text(
         "** Caption\n"
         "** Caption2\n"
         "text\n")
     set_active_view_cursor_position(2, 1)
     self.view.run_command('zorg_move_node_up')
     self.assertEqual(
         get_active_view_text(),
         "** Caption2\n"
         "text\n"
         "** Caption\n")
     self.assertEqual(get_active_view_cursor_position(), (1, 1))
コード例 #19
0
 def test_cut_section_with_src(self):
     set_active_view_text("* Header 1\n"
                          "* Header 2\n"
                          "#+BEGIN_SRC\n"
                          "* This is actually not a header\n"
                          "#+END_SRC\n"
                          " #+BEGIN_SRC\n"
                          "* This is also not a header\n"
                          " #+END_SRC \n"
                          "* Header 3\n")
     set_active_view_cursor_position(2, 1)
     get_active_view().run_command("zorg_cut_node")
     self.assertEqual(get_active_view_text(), "* Header 1\n" "* Header 3\n")
コード例 #20
0
ファイル: test_move_node.py プロジェクト: rdpli/Zorgmode
 def test_missing_new_line_at_eof(self):
     set_active_view_text(
         "** Caption\n"
         "** Caption2\n"
         "text")
     set_active_view_cursor_position(2, 1)
     self.view.run_command('zorg_move_node_up')
     self.assertEqual(
         get_active_view_text(),
         "** Caption2\n"
         "text\n"
         "** Caption")
     self.assertEqual(get_active_view_cursor_position(), (1, 1))
コード例 #21
0
ファイル: test_cut_node.py プロジェクト: dim-an/zorgmode
 def test_cut_section(self):
     set_active_view_text(
         "* Header 1\n"
         "some text\n"
         "** Header 2\n"
         "another text\n"
         "* Header 3\n"
     )
     set_active_view_cursor_position(1, 1)
     get_active_view().run_command("zorg_cut_node")
     self.assertEqual(
         get_active_view_text(),
         "* Header 3\n"
     )
コード例 #22
0
ファイル: test_archivation.py プロジェクト: rdpli/Zorgmode
    def test_subheadline_archivation(self):
        with tempfile.NamedTemporaryFile() as tmpf:
            set_active_view_text("#+ARCHIVE:{tempfile}\n"
                                 "* Header 1\n"
                                 "** Header 2\n"
                                 "* Header 3\n".format(tempfile=tmpf.name))
            set_active_view_cursor_position(3, 2)
            self.view.run_command("zorg_move_to_archive")

            self.assertEqual(
                get_active_view_text(), "#+ARCHIVE:{tempfile}\n"
                "* Header 1\n"
                "* Header 3\n".format(tempfile=tmpf.name))
            self.assertEqual(tmpf.read().decode('utf-8'), "\n* Header 2\n")
コード例 #23
0
ファイル: test_move_node.py プロジェクト: rdpli/Zorgmode
    def test_empty_lines(self):
        set_active_view_text(
            "  * 0000\n"
            "\n"
            "\n"
            "  * 1111\n"
            " \n"
            "  * 2222\n"
            " \n"
            " \n"
            " * 3333\n"
        )
        set_active_view_cursor_position(4, 1)

        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            "  * 0000\n"
            "\n"
            "\n"
            "  * 2222\n"
            " \n"
            "  * 1111\n"
            " \n"
            " \n"
            " * 3333\n"
        )
        self.assertEqual(get_active_view_cursor_position(), (6, 1))

        with self.ensure_nothing_changes():
            self.view.run_command('zorg_move_node_down')

        self.view.run_command('zorg_move_node_up')
        self.assertEqual(
            get_active_view_text(),
            "  * 0000\n"
            "\n"
            "\n"
            "  * 1111\n"
            " \n"
            "  * 2222\n"
            " \n"
            " \n"
            " * 3333\n"
        )
        self.assertEqual(get_active_view_cursor_position(), (4, 1))

        with self.ensure_nothing_changes():
            self.view.run_command('zorg_move_node_up')
コード例 #24
0
ファイル: test_move_node.py プロジェクト: rdpli/Zorgmode
    def test_ordinary_move(self):
        set_active_view_text(
            "some stuff\n"
            "** Caption\n"
            "some text\n"
            "*** Other caption\n"
            "** Caption2\n")
        set_active_view_cursor_position(1, 2)
        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            "some stuff\n"
            "** Caption\n"
            "some text\n"
            "*** Other caption\n"
            "** Caption2\n")
        self.assertEqual(get_active_view_cursor_position(), (1, 2))

        set_active_view_cursor_position(2, 3)
        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            "some stuff\n"
            "** Caption2\n"
            "** Caption\n"
            "some text\n"
            "*** Other caption\n")
        self.assertEqual(get_active_view_cursor_position(), (3, 3))

        set_active_view_cursor_position(2, 3)
        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            "some stuff\n"
            "** Caption\n"
            "some text\n"
            "*** Other caption\n"
            "** Caption2\n")
        self.assertEqual(get_active_view_cursor_position(), (5, 3))

        self.view.run_command('zorg_move_node_up')
        self.assertEqual(
            get_active_view_text(),
            "some stuff\n"
            "** Caption2\n"
            "** Caption\n"
            "some text\n"
            "*** Other caption\n")
        self.assertEqual(get_active_view_cursor_position(), (2, 3))
コード例 #25
0
ファイル: test_cut_node.py プロジェクト: dim-an/zorgmode
 def test_cut_list_entry(self):
     set_active_view_text(
         "  - foo\n"
         "  - bar\n"
         "    * baz\n"
         "     continuation of baz\n"
         "   continuation of bar\n"
         " + qux\n"
     )
     set_active_view_cursor_position(2, 1)
     get_active_view().run_command("zorg_cut_node")
     self.assertEqual(
         get_active_view_text(),
         "  - foo\n"
         " + qux\n"
     )
コード例 #26
0
ファイル: test_archivation.py プロジェクト: dim-an/zorgmode
 def test_archivation_to_nonexistent_file(self):
     set_active_view_text(
         "#+ARCHIVE:/dev/null/nonexistent_file\n"
         "* Header 1\n"
         "** Header 2\n"
         "* Header 3\n"
     )
     set_active_view_cursor_position(3, 2)
     self.view.run_command("zorg_move_to_archive", {"silent": True})
     self.assertEqual(
         get_active_view_text(),
         "#+ARCHIVE:/dev/null/nonexistent_file\n"
         "* Header 1\n"
         "** Header 2\n"
         "* Header 3\n"
     )
コード例 #27
0
    def test_toggle_checkbox(self):
        set_active_view_text("* Caption\n" " - [ ] checkbox\n")

        set_active_view_cursor_position(1, 1)
        self.view.run_command('zorg_toggle_checkbox')
        self.assertEqual(get_active_view_text(), "* Caption\n"
                         " - [ ] checkbox\n")

        set_active_view_cursor_position(2, 1)
        self.view.run_command('zorg_toggle_checkbox')
        self.assertEqual(get_active_view_text(), "* Caption\n"
                         " - [X] checkbox\n")

        set_active_view_cursor_position(2, 1)
        self.view.run_command('zorg_toggle_checkbox')
        self.assertEqual(get_active_view_text(), "* Caption\n"
                         " - [ ] checkbox\n")
コード例 #28
0
ファイル: test_move_node.py プロジェクト: rdpli/Zorgmode
    def test_other_headline(self):
        set_active_view_text(
            "** Caption\n"
            "some text\n"
            "*** Other caption\n"
            "some other text\n"
            "*** Other caption 2\n"
            "** Caption2\n"
            "*** Other caption 3\n")

        set_active_view_cursor_position(3, 5)
        self.view.run_command('zorg_move_node_up')
        self.assertEqual(
            get_active_view_text(),
            "** Caption\n"
            "some text\n"
            "*** Other caption\n"
            "some other text\n"
            "*** Other caption 2\n"
            "** Caption2\n"
            "*** Other caption 3\n")
        self.assertEqual(get_active_view_cursor_position(), (3, 5))

        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            "** Caption\n"
            "some text\n"
            "*** Other caption 2\n"
            "*** Other caption\n"
            "some other text\n"
            "** Caption2\n"
            "*** Other caption 3\n")
        self.assertEqual(get_active_view_cursor_position(), (4, 5))

        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            "** Caption\n"
            "some text\n"
            "*** Other caption 2\n"
            "*** Other caption\n"
            "some other text\n"
            "** Caption2\n"
            "*** Other caption 3\n")
        self.assertEqual(get_active_view_cursor_position(), (4, 5))
コード例 #29
0
    def test_folded(self):
        set_active_view_text("some stuff\n"
                             "** Caption{\n"
                             "some text\n"
                             "*** Other caption\n"
                             "more text}\n"
                             "** Caption 2{\n"
                             "even more text\n"
                             "}\n"
                             "* Caption 3{\n"
                             "text text text}\n"
                             "** Caption 4{\n\n}")
        set_active_view_cursor_position(1, 2)
        self.view.run_command('zorg_cycle_all')
        self.assert_proper_folding()

        self.view.run_command('zorg_cycle_all')
        self.view.run_command('zorg_cycle_all')
        self.assertEqual(self.view.folded_regions(), [])
コード例 #30
0
ファイル: test_archivation.py プロジェクト: dim-an/zorgmode
    def test_simple_archivation(self):
        with tempfile.NamedTemporaryFile() as tmpf:
            set_active_view_text(
                "#+ARCHIVE:{tempfile}\n"
                "* Header 1\n"
                "** Header 2\n"
                "* Header 3\n".format(tempfile=tmpf.name))
            set_active_view_cursor_position(2, 2)
            self.view.run_command("zorg_move_to_archive")

            self.assertEqual(
                get_active_view_text(),
                "#+ARCHIVE:{tempfile}\n"
                "* Header 3\n".format(tempfile=tmpf.name))

            self.assertEqual(
                tmpf.read().decode('utf-8'),
                ("\n* Header 1\n"
                 "** Header 2\n"))
コード例 #31
0
ファイル: test_cut_node.py プロジェクト: dim-an/zorgmode
    def test_cut_section_with_src(self):
        set_active_view_text(
            "* Header 1\n"
            "* Header 2\n"
            "#+BEGIN_SRC\n"
            "* This is actually not a header\n"
            "#+END_SRC\n"
            " #+BEGIN_SRC\n"
            "* This is also not a header\n"
            " #+END_SRC \n"
            "* Header 3\n"

        )
        set_active_view_cursor_position(2, 1)
        get_active_view().run_command("zorg_cut_node")
        self.assertEqual(
            get_active_view_text(),
            "* Header 1\n"
            "* Header 3\n"
        )
コード例 #32
0
    def test_overview(self):
        set_active_view_text(
            "some stuff\n"
            "** Caption{\n"
            "some text}\n"
            "*** Other caption{\n"
            "more text}\n"
            "** Caption 2{\n"
            "even more text\n"
            "}\n"
            "* Caption 3{\n"
            "text text text}\n"
            "** Caption 4{\n\n}"
        )
        set_active_view_cursor_position(1, 2)
        self.view.run_command('zorg_cycle_all')
        self.view.run_command('zorg_cycle_all')
        self.assert_proper_folding()

        self.view.run_command('zorg_cycle_all')
        self.assertEqual(self.view.folded_regions(), [])
コード例 #33
0
ファイル: test_move_node.py プロジェクト: rdpli/Zorgmode
    def test_respect_folding(self):
        set_active_view_text(
            "* Caption {\n"
            "some text}\n"
            "* Caption 2\n"
            "* Caption 3 {\n"
            "text\n"
            "** subsection\n"
            "more text}")
        set_active_view_cursor_position(1, 2)
        self.view.run_command('zorg_cycle_all')
        try:
            self.assertProperFolding()
        except:
            # do not want this test to spam output
            raise RuntimeError("folding is broken")

        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            "* Caption 2\n"
            "* Caption {\n"
            "some text}\n"
            "* Caption 3 {\n"
            "text\n"
            "** subsection\n"
            "more text}")
        self.assertProperFolding()

        self.view.run_command('zorg_move_node_down')
        self.assertEqual(
            get_active_view_text(),
            "* Caption 2\n"
            "* Caption 3 {\n"
            "text\n"
            "** subsection\n"
            "more text}\n"
            "* Caption {\n"
            "some text}")
コード例 #34
0
    def test_selection(self):
        set_active_view_text(
            "* Caption\n"  # 1
            " - [ ] checkbox 1\n"  # 2
            " - [X] checkbox 2\n"  # 3
            "   - [ ] checkbox 3\n"  # 4
            " - [] not a checkbox 4\n"  # 5
            " - [ ] will not be toggled\n"  # 6
        )

        view = get_active_view()
        sel = view.sel().clear()
        view.sel().add(
            sublime.Region(
                0,
                view.text_point(5, 0)
            )
        )
        self.view.run_command('zorg_toggle_checkbox')
        self.assertEqual(
            get_active_view_text(),
            "* Caption\n"
            " - [X] checkbox 1\n"
            " - [X] checkbox 2\n"
            "   - [X] checkbox 3\n"
            " - [] not a checkbox 4\n"
            " - [ ] will not be toggled\n"
        )
        self.view.run_command('zorg_toggle_checkbox')
        self.assertEqual(
            get_active_view_text(),
            "* Caption\n"
            " - [ ] checkbox 1\n"
            " - [ ] checkbox 2\n"
            "   - [ ] checkbox 3\n"
            " - [] not a checkbox 4\n"
            " - [ ] will not be toggled\n"
        )