summaryrefslogtreecommitdiffstats
path: root/tests/lint_tests/test_lint_dcpy.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 16:23:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 16:23:19 +0000
commit4d60d1035c25a28b56ccef4bc9b3e685c29a30e7 (patch)
treeb8968f140ea39151c1ef41dabeb6923523d778d3 /tests/lint_tests/test_lint_dcpy.py
parentAdding upstream version 0.1.32. (diff)
downloaddebputy-4d60d1035c25a28b56ccef4bc9b3e685c29a30e7.tar.xz
debputy-4d60d1035c25a28b56ccef4bc9b3e685c29a30e7.zip
Adding upstream version 0.1.33.upstream/0.1.33
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/lint_tests/test_lint_dcpy.py')
-rw-r--r--tests/lint_tests/test_lint_dcpy.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/lint_tests/test_lint_dcpy.py b/tests/lint_tests/test_lint_dcpy.py
new file mode 100644
index 0000000..f827d3e
--- /dev/null
+++ b/tests/lint_tests/test_lint_dcpy.py
@@ -0,0 +1,64 @@
+import textwrap
+
+import pytest
+
+from debputy.lsp.lsp_debian_copyright import _lint_debian_copyright
+from debputy.packages import DctrlParser
+from debputy.plugin.api.feature_set import PluginProvidedFeatureSet
+from lint_tests.lint_tutil import (
+ group_diagnostics_by_severity,
+ LintWrapper,
+)
+
+try:
+ from lsprotocol.types import Diagnostic, DiagnosticSeverity
+except ImportError:
+ pass
+
+
+@pytest.fixture
+def line_linter(
+ debputy_plugin_feature_set: PluginProvidedFeatureSet,
+ lint_dctrl_parser: DctrlParser,
+) -> LintWrapper:
+ return LintWrapper(
+ "/nowhere/debian/copyright",
+ _lint_debian_copyright,
+ debputy_plugin_feature_set,
+ lint_dctrl_parser,
+ )
+
+
+def test_dcpy_files_lint(line_linter: LintWrapper) -> None:
+ lines = textwrap.dedent(
+ """\
+ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+
+ Files: foo .//unnecessary///many/slashes
+ Copyright: Noone <noone@example.com>
+ License: something
+ yada yada yada
+ """
+ ).splitlines(keepends=True)
+
+ diagnostics = line_linter(lines)
+ by_severity = group_diagnostics_by_severity(diagnostics)
+ assert DiagnosticSeverity.Warning in by_severity
+
+ assert DiagnosticSeverity.Error not in by_severity
+ assert DiagnosticSeverity.Hint not in by_severity
+ assert DiagnosticSeverity.Information not in by_severity
+
+ warnings = by_severity[DiagnosticSeverity.Warning]
+ print(warnings)
+ assert len(warnings) == 2
+
+ first_warn, second_warn = warnings
+
+ msg = 'Unnecessary prefix ".//"'
+ assert first_warn.message == msg
+ assert f"{first_warn.range}" == "2:11-2:14"
+
+ msg = 'Simplify to a single "/"'
+ assert second_warn.message == msg
+ assert f"{second_warn.range}" == "2:25-2:28"