All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
4 ale_module = imp.load_source(
5 'deoplete.sources.ale',
6 '/testplugin/rplugin/python3/deoplete/sources/ale.py',
10 class VimMock(object):
11 def __init__(self, call_list, call_results, commands):
12 self.__call_list = call_list
13 self.__call_results = call_results
15 self.__commands = commands
17 def call(self, function, *args):
18 self.__call_list.append((function, args))
20 return self.__call_results.get(function, 0)
22 def command(self, command):
23 self.__commands.append(command)
26 class DeopleteSourceTest(unittest.TestCase):
28 super(DeopleteSourceTest, self).setUp()
31 self.call_results = {'ale#completion#CanProvideCompletions': 1}
33 self.source = ale_module.Source('vim')
34 self.source.vim = VimMock(
35 self.call_list, self.call_results, self.commands)
37 def test_attributes(self):
39 Check all of the attributes we set.
42 (key, getattr(self.source, key))
45 if not key.startswith('__')
47 and not hasattr(getattr(self.source, key), '__self__')
50 self.assertEqual(attributes, {
53 'rust': r'(\.|::)\w*$',
54 'typescript': r'(\.|\'|")\w*$',
55 'cpp': r'(\.|::|->)\w*$',
61 'min_pattern_length': 1,
66 def test_complete_position(self):
67 self.call_results['ale#completion#GetCompletionPositionForDeoplete'] = 2
68 context = {'input': 'foo'}
70 self.assertEqual(self.source.get_complete_position(context), 2)
71 self.assertEqual(self.call_list, [
72 ('ale#completion#GetCompletionPositionForDeoplete', ('foo',)),
75 def test_request_completion_results(self):
76 context = {'event': 'TextChangedI', 'is_refresh': True}
78 self.assertEqual(self.source.gather_candidates(context), [])
79 self.assertEqual(self.call_list, [
80 ('ale#completion#CanProvideCompletions', ()),
82 self.assertEqual(self.commands, [
83 "call ale#completion#GetCompletions('ale-callback', " + \
84 "{'callback': {completions -> deoplete#auto_complete() }})"
87 def test_request_completion_results_from_buffer_without_providers(self):
88 self.call_results['ale#completion#CanProvideCompletions'] = 0
89 context = {'event': 'TextChangedI', 'is_refresh': True}
91 self.assertIsNone(self.source.gather_candidates(context), [])
92 self.assertEqual(self.call_list, [
93 ('ale#completion#CanProvideCompletions', ()),
96 def test_async_event(self):
97 context = {'event': 'Async', 'is_refresh': True}
98 self.call_results['ale#completion#GetCompletionResult'] = [
108 self.assertEqual(self.source.gather_candidates(context), [
118 self.assertEqual(self.call_list, [
119 ('ale#completion#CanProvideCompletions', ()),
120 ('ale#completion#GetCompletionResult', ()),