summaryrefslogtreecommitdiffstats
path: root/tests/lsp_tests/test_lsp_dctrl.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 20:16:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 20:16:53 +0000
commitee65fb850961435a3c8ed89ffb20d16f0e8505a3 (patch)
tree1fe559c0b1c6a2244e0e87e94c1d98222fa02e8c /tests/lsp_tests/test_lsp_dctrl.py
parentAdding upstream version 0.1.24. (diff)
downloaddebputy-upstream/0.1.25.tar.xz
debputy-upstream/0.1.25.zip
Adding upstream version 0.1.25.upstream/0.1.25
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/lsp_tests/test_lsp_dctrl.py')
-rw-r--r--tests/lsp_tests/test_lsp_dctrl.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/lsp_tests/test_lsp_dctrl.py b/tests/lsp_tests/test_lsp_dctrl.py
new file mode 100644
index 0000000..2a2466f
--- /dev/null
+++ b/tests/lsp_tests/test_lsp_dctrl.py
@@ -0,0 +1,72 @@
+import textwrap
+
+try:
+ from lsprotocol.types import (
+ CompletionParams,
+ TextDocumentIdentifier,
+ HoverParams,
+ MarkupContent,
+ )
+
+ from debputy.lsp.lsp_debian_control import (
+ _debian_control_completions,
+ _debian_control_hover,
+ )
+
+ from pygls.server import LanguageServer
+except ImportError:
+ pass
+from lsp_tests.lsp_tutil import put_doc_with_cursor
+
+
+def test_dctrl_complete_field(ls: "LanguageServer") -> None:
+ dctrl_uri = "file:///nowhere/debian/control"
+
+ cursor_pos = put_doc_with_cursor(
+ ls,
+ dctrl_uri,
+ "debian/control",
+ textwrap.dedent(
+ """\
+ Source: foo
+
+ Package: foo
+ <CURSOR>
+"""
+ ),
+ )
+ matches = _debian_control_completions(
+ ls,
+ CompletionParams(TextDocumentIdentifier(dctrl_uri), cursor_pos),
+ )
+ assert matches
+ keywords = {m.label for m in matches}
+ assert "Multi-Arch" in keywords
+ assert "Architecture" in keywords
+ # Already present or wrong section
+ assert "Package" not in keywords
+ assert "Source" not in keywords
+
+
+def test_dctrl_hover_doc_field(ls: "LanguageServer") -> None:
+ dctrl_uri = "file:///nowhere/debian/control"
+ cursor_pos = put_doc_with_cursor(
+ ls,
+ dctrl_uri,
+ "debian/control",
+ textwrap.dedent(
+ """\
+ Source: foo
+
+ Package: foo
+ Arch<CURSOR>itecture: any
+"""
+ ),
+ )
+
+ hover_doc = _debian_control_hover(
+ ls,
+ HoverParams(TextDocumentIdentifier(dctrl_uri), cursor_pos),
+ )
+ assert hover_doc is not None and isinstance(hover_doc.contents, MarkupContent)
+ assert "Determines which architecture" in hover_doc.contents.value