def test_complete_plugin(magic, patch):
    patch.init(Document)
    patch.many(Document, ['line_to_cursor', 'word_to_cursor'])
    patch.many(CompletionContext, ['_blocks'])
    my_plugin = magic()
    i1 = {'label': 'i1'}
    i2 = {'label': 'i2'}
    cache = magic()
    my_plugin.complete.return_value = [i1, i2]
    c = Completion(plugins=[my_plugin], context_cache=cache)
    doc = Document()
    ws = magic()
    pos = magic()
    result = c.complete(ws, doc, pos)
    assert isinstance(my_plugin.complete.call_args[0][0], CompletionContext)
    assert (result == {'isIncomplete': False, 'items': [i1, i2]})
def test_complete_plugin(magic, patch):
    patch.init(Document)
    patch.many(Document, ['line_to_cursor', 'word_to_cursor'])
    patch.many(CompletionContext, ['_blocks'])
    my_plugin = magic()
    i1 = {'label': 'i1'}
    i2 = {'label': 'i2'}
    cache = magic()
    my_plugin.complete.return_value = [i1, i2]
    c = Completion(plugins=[my_plugin], context_cache=cache)
    doc = Document()
    ws = magic()
    pos = magic()
    result = c.complete(ws, doc, pos)
    assert isinstance(my_plugin.complete.call_args[0][0], CompletionContext)
    assert (result == {'isIncomplete': False, 'items': [i1, i2]})