From 021b9a5efd696e783f1071e36324b465f60bbc90 Mon Sep 17 00:00:00 2001 From: Alex Carney Date: Sun, 12 Nov 2023 19:06:56 +0000 Subject: [PATCH] pytest-lsp: Add checks for `window/workDoneProgress/create` --- lib/pytest-lsp/pytest_lsp/checks.py | 11 +++++++++++ lib/pytest-lsp/tests/test_checks.py | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/pytest-lsp/pytest_lsp/checks.py b/lib/pytest-lsp/pytest_lsp/checks.py index e004b50..1dd9e3e 100644 --- a/lib/pytest-lsp/pytest_lsp/checks.py +++ b/lib/pytest-lsp/pytest_lsp/checks.py @@ -245,6 +245,17 @@ def document_links( assert tooltip_support, "Client does not support tooltips." +@check_params_of(method=types.WINDOW_WORK_DONE_PROGRESS_CREATE) +def work_done_progress_create( + capabilities: types.ClientCapabilities, + params: types.WorkDoneProgressCreateParams, +): + """Assert that the client has support for ``window/workDoneProgress/create`` + requests.""" + is_supported = get_capability(capabilities, "window.workDoneProgress", False) + assert is_supported, "Client does not support 'window/workDoneProgress/create'" + + @check_params_of(method=types.WORKSPACE_CONFIGURATION) def workspace_configuration( capabilities: types.ClientCapabilities, diff --git a/lib/pytest-lsp/tests/test_checks.py b/lib/pytest-lsp/tests/test_checks.py index 3a6c676..8cf6ccf 100644 --- a/lib/pytest-lsp/tests/test_checks.py +++ b/lib/pytest-lsp/tests/test_checks.py @@ -14,6 +14,14 @@ @pytest.mark.parametrize( "capabilities,method,params,expected", [ + ( + types.ClientCapabilities( + window=types.WindowClientCapabilities(work_done_progress=False) + ), + types.WINDOW_WORK_DONE_PROGRESS_CREATE, + types.WorkDoneProgressCreateParams(token="id-123"), + "does not support 'window/workDoneProgress/create'", + ), ( types.ClientCapabilities( workspace=types.WorkspaceClientCapabilities(configuration=False)