-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add structure hook for
Union[str, List[InlayHintLabelPart]]
- Loading branch information
Showing
2 changed files
with
101 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import json | ||
import uuid | ||
|
||
import hamcrest | ||
import jsonrpc | ||
import pytest | ||
from cattrs.errors import ClassValidationError | ||
|
||
ID = str(uuid.uuid4()) | ||
|
||
TEST_DATA = [ | ||
( | ||
{ | ||
"id": ID, | ||
"method": "inlayHint/resolve", | ||
"params": { | ||
"position": {"line": 6, "character": 5}, | ||
"label": "a label", | ||
"kind": 1, | ||
"paddingLeft": False, | ||
"paddingRight": True, | ||
}, | ||
"jsonrpc": "2.0", | ||
}, | ||
json.dumps( | ||
{ | ||
"id": ID, | ||
"params": { | ||
"position": {"line": 6, "character": 5}, | ||
"label": "a label", | ||
"kind": 1, | ||
"paddingLeft": False, | ||
"paddingRight": True, | ||
}, | ||
"method": "inlayHint/resolve", | ||
"jsonrpc": "2.0", | ||
} | ||
), | ||
), | ||
( | ||
{ | ||
"id": ID, | ||
"method": "inlayHint/resolve", | ||
"params": { | ||
"position": {"line": 6, "character": 5}, | ||
"label": [ | ||
{"value": "part 1"}, | ||
{"value": "part 2", "tooltip": "a tooltip"}, | ||
], | ||
"kind": 1, | ||
"paddingLeft": False, | ||
"paddingRight": True, | ||
}, | ||
"jsonrpc": "2.0", | ||
}, | ||
json.dumps( | ||
{ | ||
"id": ID, | ||
"params": { | ||
"position": {"line": 6, "character": 5}, | ||
"label": [ | ||
{"value": "part 1"}, | ||
{"value": "part 2", "tooltip": "a tooltip"}, | ||
], | ||
"kind": 1, | ||
"paddingLeft": False, | ||
"paddingRight": True, | ||
}, | ||
"method": "inlayHint/resolve", | ||
"jsonrpc": "2.0", | ||
} | ||
), | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("index", list(range(0, len(TEST_DATA)))) | ||
def test_inlay_hint_resolve_request_serialization(index): | ||
data, expected = TEST_DATA[index] | ||
data_str = json.dumps(data) | ||
parsed = jsonrpc.from_json(data_str) | ||
actual_str = jsonrpc.to_json(parsed) | ||
hamcrest.assert_that(actual_str, hamcrest.is_(expected)) |