Skip to content

Commit 9093070

Browse files
committed
Create a test for progress reporting in the initialize request
1 parent 6e16a34 commit 9093070

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
project Hello is
2+
3+
end Hello;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# The goal of this test is to check that if the initialize request includes a progress
2+
# reporting token, then progress is reported by the ALS.
3+
import os
4+
5+
from drivers import pylsp
6+
from drivers.pylsp import URI, to_str
7+
from lsprotocol.types import ClientCapabilities, InitializeParams, InitializedParams
8+
9+
10+
@pylsp.test(initialize=False)
11+
async def test(lsp: pylsp.ALSLanguageClient):
12+
lsp.capabilities = ClientCapabilities()
13+
progress_token = "init-progress"
14+
result = await lsp.initialize_async(
15+
InitializeParams(
16+
capabilities=lsp.capabilities,
17+
root_uri=URI(os.getcwd()),
18+
initialization_options={},
19+
# Include a progress token to check that we receive progress reports during
20+
# the initialize request
21+
work_done_token=progress_token,
22+
)
23+
)
24+
25+
# Assert that we received progress reports
26+
lsp.assertEqual(
27+
to_str(lsp.progress_reports.get(progress_token, None)),
28+
"""
29+
[
30+
{
31+
"title": "Initializing Ada Language Server",
32+
"kind": "begin",
33+
"cancellable": false
34+
},
35+
{
36+
"kind": "end"
37+
}
38+
]
39+
""".strip(),
40+
)
41+
42+
# Assert a non-null result
43+
lsp.assertNotEqual(result, None)
44+
45+
lsp.initialized(InitializedParams())
46+
47+
lsp.assertEqual(await lsp.getCurrentProject(), URI("hello.gpr"))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
driver: pylsp

0 commit comments

Comments
 (0)