Ejemplo n.º 1
0
    def _helper_completion_tests(self, result_list, **isolation_args):
        """
        Use the isolation helper to set up the environment and compare the
        results from complete_local_matches with the given result_list.
        """
        with self._helper_isolate_buffer_matches(
                **isolation_args) as transmit_result_mock:

            localcomplete.complete_all_buffer_matches()

        transmit_result_mock.assert_called_once_with(result_list)
    def _helper_completion_tests(self,
            result_list,
            **isolation_args):
        """
        Use the isolation helper to set up the environment and compare the
        results from complete_local_matches with the given result_list.
        """
        with self._helper_isolate_buffer_matches(**isolation_args
                ) as transmit_result_mock:

            localcomplete.complete_all_buffer_matches()

        transmit_result_mock.assert_called_once_with(result_list)
Ejemplo n.º 3
0
    def test_final_vim_result_command_without_origin_note(self):
        isolation_args = dict(
            buffers_content=["onea two".split(), "x y onez".split(), "", "a oneb c".split()],
            current_buffer_index=0,
            show_origin=0,
            keyword_base="one",
        )
        result_value = """[{'word': "onea"}, """ """{'word': "onez"}, {'word': "oneb"}]"""

        with self._helper_isolate_sut(**isolation_args) as vim_mock:
            localcomplete.complete_all_buffer_matches()

        result_command = localcomplete.VIM_COMMAND_BUFFERCOMPLETE % result_value
        vim_mock.command.assert_called_once_with(result_command)
Ejemplo n.º 4
0
    def test_standard_search_across_multiple_buffers(self):
        isolation_args = dict(
            buffers_content=["ONEa two".split(), "", "x y onez".split(), "", "a oneb c".split(), ""],
            want_ignorecase_local=1,
            current_buffer_index=2,
            keyword_base="one",
        )
        result_list = u"onez onea oneb".split()

        produce_mock = mock.Mock(spec_set=[], return_value=[])
        with mock.patch.multiple(__name__ + ".localcomplete", produce_result_value=produce_mock):
            with self._helper_isolate_sut(**isolation_args) as vim_mock:
                localcomplete.complete_all_buffer_matches()

        produce_mock.assert_called_once_with(result_list, mock.ANY)
        self.assertEqual(vim_mock.command.call_count, 1)
    def test_standard_search_across_multiple_buffers(self):
        isolation_args = dict(buffers_content=[
            "ONEa two".split(), "", "x y onez".split(), "", "a oneb c".split(),
            ""
        ],
                              want_ignorecase_local=1,
                              current_buffer_index=2,
                              keyword_base="one")
        result_list = u"onez onea oneb".split()

        produce_mock = mock.Mock(spec_set=[], return_value=[])
        with mock.patch.multiple(__name__ + '.localcomplete',
                                 produce_result_value=produce_mock):
            with self._helper_isolate_sut(**isolation_args) as vim_mock:
                localcomplete.complete_all_buffer_matches()

        produce_mock.assert_called_once_with(result_list, mock.ANY)
        self.assertEqual(vim_mock.command.call_count, 1)
    def test_final_vim_result_command_without_origin_note(self):
        isolation_args = dict(buffers_content=[
            "onea two".split(),
            "x y onez".split(),
            "",
            "a oneb c".split(),
        ],
                              current_buffer_index=0,
                              show_origin=0,
                              keyword_base="one")
        result_value = ("""[{'word': "onea"}, """
                        """{'word': "onez"}, {'word': "oneb"}]""")

        with self._helper_isolate_sut(**isolation_args) as vim_mock:
            localcomplete.complete_all_buffer_matches()

        result_command = (localcomplete.VIM_COMMAND_BUFFERCOMPLETE %
                          result_value)
        vim_mock.command.assert_called_once_with(result_command)
    def test_transmits_found_matches_to_vim(self):
        result_list = ['results']
        buffers_contents = ['contents']
        min_len = 3

        vim_mock = VimMockFactory.get_mock(min_len_all_buffer=min_len)
        find_mock = mock.Mock(spec_set=[], return_value=result_list)
        buffers_mock = mock.Mock(spec_set=[], return_value=buffers_contents)
        transmit_result_mock = mock.Mock(spec_set=[], return_value=[])

        with mock.patch.multiple(
                __name__ + '.localcomplete',
                find_matches_in_lines=find_mock,
                generate_all_buffer_lines=buffers_mock,
                transmit_all_buffer_result_to_vim=transmit_result_mock,
                vim=vim_mock):
            localcomplete.complete_all_buffer_matches()

        find_mock.assert_called_once_with(buffers_contents, min_len)
        transmit_result_mock.assert_called_once_with(result_list)