-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pytest-lsp: Add spec compliance check for
workspace/configuration
The `LanguageClientProtocol` class is now also able to perform complicance checks on incoming requests from the server under test. The first check implemented is making sure that the client has support for `workspace/configuration` requests.
- Loading branch information
Showing
3 changed files
with
218 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from typing import Any | ||
|
||
import pytest | ||
from lsprotocol import types | ||
|
||
from pytest_lsp import checks | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"capabilities,method,params,expected", | ||
[ | ||
( | ||
types.ClientCapabilities( | ||
workspace=types.WorkspaceClientCapabilities(configuration=False) | ||
), | ||
types.WORKSPACE_CONFIGURATION, | ||
types.WorkspaceConfigurationParams(items=[]), | ||
"does not support 'workspace/configuration'", | ||
), | ||
], | ||
) | ||
def test_params_check_warning( | ||
capabilities: types.ClientCapabilities, method: str, params: Any, expected: str | ||
): | ||
"""Ensure that parameter checks work as expected. | ||
Parameters | ||
---------- | ||
capabilities | ||
The client's capabilities | ||
method | ||
The method name to check | ||
params | ||
The params to check | ||
expected | ||
The expected warning message | ||
""" | ||
|
||
with pytest.warns(checks.LspSpecificationWarning, match=expected): | ||
checks.check_params_against_client_capabilities(capabilities, method, params) |