2015-12-31 18:14:26 -05:00
|
|
|
# Copyright (C) 2016 YouCompleteMe contributors
|
|
|
|
#
|
|
|
|
# This file is part of YouCompleteMe.
|
|
|
|
#
|
|
|
|
# YouCompleteMe is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# YouCompleteMe is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-02-27 19:12:24 -05:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import division
|
|
|
|
from __future__ import absolute_import
|
2017-03-09 09:57:27 -05:00
|
|
|
# Not installing aliases from python-future; it's unreliable and slow.
|
2016-02-27 19:12:24 -05:00
|
|
|
from builtins import * # noqa
|
2015-12-31 18:14:26 -05:00
|
|
|
|
|
|
|
from mock import MagicMock
|
|
|
|
from nose.tools import eq_
|
|
|
|
|
|
|
|
from ycm.client.omni_completion_request import OmniCompletionRequest
|
|
|
|
|
|
|
|
|
2017-02-04 15:46:54 -05:00
|
|
|
def BuildOmnicompletionRequest( results, start_column = 1 ):
|
2015-12-31 18:14:26 -05:00
|
|
|
omni_completer = MagicMock()
|
|
|
|
omni_completer.ComputeCandidates = MagicMock( return_value = results )
|
|
|
|
|
2017-02-04 15:46:54 -05:00
|
|
|
request_data = {
|
2018-10-19 09:59:41 -04:00
|
|
|
'line_num': 1,
|
|
|
|
'column_num': 1,
|
2017-02-04 15:46:54 -05:00
|
|
|
'start_column': start_column
|
|
|
|
}
|
|
|
|
request = OmniCompletionRequest( omni_completer, request_data )
|
2015-12-31 18:14:26 -05:00
|
|
|
request.Start()
|
|
|
|
|
2016-03-06 12:13:43 -05:00
|
|
|
return request
|
2015-12-31 18:14:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
def Done_AlwaysTrue_test():
|
|
|
|
request = BuildOmnicompletionRequest( [] )
|
|
|
|
|
|
|
|
eq_( request.Done(), True )
|
|
|
|
|
|
|
|
|
|
|
|
def Response_FromOmniCompleter_test():
|
|
|
|
results = [ { "word": "test" } ]
|
|
|
|
request = BuildOmnicompletionRequest( results )
|
|
|
|
|
2017-02-04 15:46:54 -05:00
|
|
|
eq_( request.Response(), {
|
2018-10-19 09:59:41 -04:00
|
|
|
'line': 1,
|
|
|
|
'column': 1,
|
|
|
|
'completion_start_column': 1,
|
|
|
|
'completions': results
|
2017-02-04 15:46:54 -05:00
|
|
|
} )
|