Skip to content

Commit de25364

Browse files
committed
Replace completion_auto_qualifier test with python test
1 parent a389bc5 commit de25364

File tree

6 files changed

+68
-276
lines changed

6 files changed

+68
-276
lines changed

testsuite/ada_lsp/completion.auto_qualifier/test.json

Lines changed: 0 additions & 276 deletions
This file was deleted.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from typing import List
2+
from drivers import pylsp
3+
from lsprotocol.types import (
4+
Command,
5+
CompletionContext,
6+
CompletionItem,
7+
CompletionList,
8+
CompletionParams,
9+
CompletionTriggerKind,
10+
TextDocumentIdentifier,
11+
)
12+
13+
14+
@pylsp.test()
15+
async def test(lsp: pylsp.ALSLanguageClient) -> None:
16+
file_uri = lsp.didOpenFile("main.adb")
17+
18+
await lsp.awaitIndexingEnd()
19+
20+
result = await lsp.text_document_completion_async(
21+
CompletionParams(
22+
TextDocumentIdentifier(file_uri),
23+
pylsp.Pos(6, 26),
24+
CompletionContext(CompletionTriggerKind.Invoked),
25+
)
26+
)
27+
EXPECTED_LABEL = "LFtip (invisible)"
28+
EXPECTED_COMMAND = Command(
29+
title="",
30+
command="als-auto-import",
31+
arguments=[
32+
{
33+
"context": pylsp.URI("default.gpr"),
34+
"where": {
35+
"textDocument": {"uri": file_uri},
36+
"position": {"line": 5, "character": 20},
37+
},
38+
"import": "A",
39+
"qualifier": "A",
40+
}
41+
],
42+
)
43+
44+
def find_expected_completion_item(
45+
items: List[CompletionItem],
46+
expected_label,
47+
expected_command,
48+
):
49+
"""
50+
Find the expected completion item in the given completion items' list
51+
"""
52+
expected_items = [
53+
item
54+
for item in items
55+
if item.label == expected_label and item.command == expected_command
56+
]
57+
return len(expected_items) == 1
58+
59+
# Verify that we are able to find the expected completion invisible item
60+
# for 'LFtip'
61+
assert isinstance(
62+
result, CompletionList
63+
), "The returned completion list result should be of type CompletionList"
64+
lsp.assertEqual(
65+
find_expected_completion_item(result.items, EXPECTED_LABEL, EXPECTED_COMMAND),
66+
True,
67+
)
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
title: 'completion.auto_qualifier'
2+
driver: pylsp

0 commit comments

Comments
 (0)