예제 #1
0
    def test_request_completions(self):

        listener = StackIDEAutocompleteHandler()
        (window, view) = default_mock_window()
        view.settings().get = Mock(return_value=False)
        backend = setup_mock_backend(window)

        listener.on_query_completions(view, 'm', []) #locations not used.

        req = Req.get_autocompletion(filepath=util.relative_view_file_name(view),prefix="m")
        req['seq'] = ANY
        backend.send_request.assert_called_with(req)
예제 #2
0
    def test_returns_completions(self):
        listener = StackIDEAutocompleteHandler()
        (window, view) = default_mock_window()
        view.settings().get = Mock(side_effect=[False, True])
        setup_fake_backend(window, {'RequestGetAutocompletion': many_completions})

        completions = listener.on_query_completions(view, 'm', []) #locations not used.

        self.assertEqual(8, len(completions))
        self.assertEqual(['!!\t\tData.List', '!!'], completions[0])

        # in live situations on_query_completions returns [] first while we retrieve results
        # here we make sure that the re-trigger calls are still in place
        view.run_command.assert_any_call('hide_auto_complete')
        view.run_command.assert_any_call('auto_complete', ANY)