Skip to content

Commit 5724653

Browse files
committed
[tests] add: the first insanly basic tests
1 parent 7b4238b commit 5724653

File tree

8 files changed

+573
-0
lines changed

8 files changed

+573
-0
lines changed

noxfile.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""Configure nox."""
2+
3+
import nox
4+
5+
NOX_SESSION = nox.session(python=False)
6+
7+
8+
@NOX_SESSION
9+
def fix(session: nox.Session):
10+
"""Fix files inplace."""
11+
session.run("ruff", "format", "-s", ".")
12+
session.run("ruff", "check", "-se", "--fix", ".")
13+
14+
15+
@NOX_SESSION
16+
def lint(session: nox.Session):
17+
"""Check file formatting that only have to do with formatting."""
18+
session.run("ruff", "format", "--check", ".")
19+
session.run("ruff", "check", ".")
20+
21+
22+
@NOX_SESSION
23+
def typecheck(session: nox.Session):
24+
session.run("mypy", "nwscript_language_server")
25+
26+
27+
@NOX_SESSION
28+
def tests(session: nox.Session):
29+
session.run("pytest", "tests")
30+
31+
32+
@NOX_SESSION
33+
def coverage(session: nox.Session):
34+
session.run(
35+
"pytest",
36+
"--cov",
37+
"nwscript_language_server",
38+
"--cov-report",
39+
"term-missing",
40+
"tests",
41+
)

tests/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.

tests/lsp_test_client/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.

tests/lsp_test_client/constants.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
"""
4+
Constants for use with tests.
5+
"""
6+
import pathlib
7+
8+
TEST_ROOT = pathlib.Path(__file__).parent.parent
9+
PROJECT_ROOT = TEST_ROOT.parent.parent.parent
10+
TEST_DATA = TEST_ROOT / "test_data"

tests/lsp_test_client/defaults.py

+219
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
"""
4+
Default initialize request params.
5+
"""
6+
7+
import os
8+
9+
from .constants import PROJECT_ROOT
10+
from .utils import as_uri, get_initialization_options
11+
12+
VSCODE_DEFAULT_INITIALIZE = {
13+
"processId": os.getpid(),
14+
"clientInfo": {"name": "vscode", "version": "1.45.0"},
15+
"rootPath": str(PROJECT_ROOT),
16+
"rootUri": as_uri(str(PROJECT_ROOT)),
17+
"capabilities": {
18+
"workspace": {
19+
"applyEdit": True,
20+
"workspaceEdit": {
21+
"documentChanges": True,
22+
"resourceOperations": ["create", "rename", "delete"],
23+
"failureHandling": "textOnlyTransactional",
24+
},
25+
"didChangeConfiguration": {"dynamicRegistration": True},
26+
"didChangeWatchedFiles": {"dynamicRegistration": True},
27+
"symbol": {
28+
"dynamicRegistration": True,
29+
"symbolKind": {
30+
"valueSet": [
31+
1,
32+
2,
33+
3,
34+
4,
35+
5,
36+
6,
37+
7,
38+
8,
39+
9,
40+
10,
41+
11,
42+
12,
43+
13,
44+
14,
45+
15,
46+
16,
47+
17,
48+
18,
49+
19,
50+
20,
51+
21,
52+
22,
53+
23,
54+
24,
55+
25,
56+
26,
57+
]
58+
},
59+
"tagSupport": {"valueSet": [1]},
60+
},
61+
"executeCommand": {"dynamicRegistration": True},
62+
"configuration": True,
63+
"workspaceFolders": True,
64+
},
65+
"textDocument": {
66+
"publishDiagnostics": {
67+
"relatedInformation": True,
68+
"versionSupport": False,
69+
"tagSupport": {"valueSet": [1, 2]},
70+
"complexDiagnosticCodeSupport": True,
71+
},
72+
"synchronization": {
73+
"dynamicRegistration": True,
74+
"willSave": True,
75+
"willSaveWaitUntil": True,
76+
"didSave": True,
77+
},
78+
"completion": {
79+
"dynamicRegistration": True,
80+
"contextSupport": True,
81+
"completionItem": {
82+
"snippetSupport": True,
83+
"commitCharactersSupport": True,
84+
"documentationFormat": ["markdown", "plaintext"],
85+
"deprecatedSupport": True,
86+
"preselectSupport": True,
87+
"tagSupport": {"valueSet": [1]},
88+
"insertReplaceSupport": True,
89+
},
90+
"completionItemKind": {
91+
"valueSet": [
92+
1,
93+
2,
94+
3,
95+
4,
96+
5,
97+
6,
98+
7,
99+
8,
100+
9,
101+
10,
102+
11,
103+
12,
104+
13,
105+
14,
106+
15,
107+
16,
108+
17,
109+
18,
110+
19,
111+
20,
112+
21,
113+
22,
114+
23,
115+
24,
116+
25,
117+
]
118+
},
119+
},
120+
"hover": {
121+
"dynamicRegistration": True,
122+
"contentFormat": ["markdown", "plaintext"],
123+
},
124+
"signatureHelp": {
125+
"dynamicRegistration": True,
126+
"signatureInformation": {
127+
"documentationFormat": ["markdown", "plaintext"],
128+
"parameterInformation": {"labelOffsetSupport": True},
129+
},
130+
"contextSupport": True,
131+
},
132+
"definition": {"dynamicRegistration": True, "linkSupport": True},
133+
"references": {"dynamicRegistration": True},
134+
"documentHighlight": {"dynamicRegistration": True},
135+
"documentSymbol": {
136+
"dynamicRegistration": True,
137+
"symbolKind": {
138+
"valueSet": [
139+
1,
140+
2,
141+
3,
142+
4,
143+
5,
144+
6,
145+
7,
146+
8,
147+
9,
148+
10,
149+
11,
150+
12,
151+
13,
152+
14,
153+
15,
154+
16,
155+
17,
156+
18,
157+
19,
158+
20,
159+
21,
160+
22,
161+
23,
162+
24,
163+
25,
164+
26,
165+
]
166+
},
167+
"hierarchicalDocumentSymbolSupport": True,
168+
"tagSupport": {"valueSet": [1]},
169+
},
170+
"codeAction": {
171+
"dynamicRegistration": True,
172+
"isPreferredSupport": True,
173+
"codeActionLiteralSupport": {
174+
"codeActionKind": {
175+
"valueSet": [
176+
"",
177+
"quickfix",
178+
"refactor",
179+
"refactor.extract",
180+
"refactor.inline",
181+
"refactor.rewrite",
182+
"source",
183+
"source.organizeImports",
184+
]
185+
}
186+
},
187+
},
188+
"codeLens": {"dynamicRegistration": True},
189+
"formatting": {"dynamicRegistration": True},
190+
"rangeFormatting": {"dynamicRegistration": True},
191+
"onTypeFormatting": {"dynamicRegistration": True},
192+
"rename": {"dynamicRegistration": True, "prepareSupport": True},
193+
"documentLink": {
194+
"dynamicRegistration": True,
195+
"tooltipSupport": True,
196+
},
197+
"typeDefinition": {
198+
"dynamicRegistration": True,
199+
"linkSupport": True,
200+
},
201+
"implementation": {
202+
"dynamicRegistration": True,
203+
"linkSupport": True,
204+
},
205+
"colorProvider": {"dynamicRegistration": True},
206+
"foldingRange": {
207+
"dynamicRegistration": True,
208+
"rangeLimit": 5000,
209+
"lineFoldingOnly": True,
210+
},
211+
"declaration": {"dynamicRegistration": True, "linkSupport": True},
212+
"selectionRange": {"dynamicRegistration": True},
213+
},
214+
"window": {"workDoneProgress": True},
215+
},
216+
"trace": "verbose",
217+
"workspaceFolders": [{"uri": as_uri(str(PROJECT_ROOT)), "name": "my_project"}],
218+
"initializationOptions": get_initialization_options(),
219+
}

0 commit comments

Comments
 (0)