|
| 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")) |
0 commit comments