1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
import textwrap
import pytest
from debputy.lsp.languages.lsp_debian_upstream_metadata import (
_lint_debian_upstream_metadata,
)
from debputy.packages import DctrlParser
from debputy.plugin.api.feature_set import PluginProvidedFeatureSet
from lint_tests.lint_tutil import (
LintWrapper,
)
from debputy.lsprotocol.types import DiagnosticSeverity
@pytest.fixture
def line_linter(
debputy_plugin_feature_set: PluginProvidedFeatureSet,
lint_dctrl_parser: DctrlParser,
) -> LintWrapper:
return LintWrapper(
"/nowhere/debian/upstream/metadata",
_lint_debian_upstream_metadata,
debputy_plugin_feature_set,
lint_dctrl_parser,
)
def test_metadata_lint_unknown_keys(line_linter: LintWrapper) -> None:
lines = textwrap.dedent(
"""\
Bar: bar
# Valid keys
Registry:
- Name: bio.tools
Entry: clustalw
- Name: OMICtools
Entry: OMICS_02562
- Name: SciCrunch
Entry: SCR_002909
Repository: https://git.example.com/repo.git
"""
).splitlines(keepends=True)
diagnostics = line_linter(lines)
print(diagnostics)
assert len(diagnostics) == 1
error = diagnostics[0]
msg = 'Unknown or unsupported key "Bar".'
assert error.message == msg
assert error.severity == DiagnosticSeverity.Warning
assert f"{error.range}" == "0:0-0:3"
|