summaryrefslogtreecommitdiffstats
path: root/tests/test_style.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 10:22:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 10:22:28 +0000
commit9a0e5a4c02dd1b3d88151dd00d1368195d22d174 (patch)
tree0a5ef7487aad3ff8999f333b0932d843f284041a /tests/test_style.py
parentReleasing progress-linux version 0.1.43-0.0~progress7.99u1. (diff)
downloaddebputy-9a0e5a4c02dd1b3d88151dd00d1368195d22d174.tar.xz
debputy-9a0e5a4c02dd1b3d88151dd00d1368195d22d174.zip
Merging upstream version 0.1.44.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_style.py')
-rw-r--r--tests/test_style.py51
1 files changed, 31 insertions, 20 deletions
diff --git a/tests/test_style.py b/tests/test_style.py
index ef6ddc4..d3cfb14 100644
--- a/tests/test_style.py
+++ b/tests/test_style.py
@@ -4,9 +4,9 @@ import pytest
from debian.deb822 import Deb822
from debputy.yaml.compat import CommentedMap
-from debputy.lsp.style_prefs import (
- StylePreferenceTable,
- determine_effective_style,
+from debputy.lsp.maint_prefs import (
+ MaintainerPreferenceTable,
+ determine_effective_preference,
EffectivePreference,
_WAS_DEFAULTS,
)
@@ -14,7 +14,7 @@ from debputy.packages import SourcePackage
def test_load_styles() -> None:
- styles = StylePreferenceTable.load_styles()
+ styles = MaintainerPreferenceTable.load_preferences()
assert "niels@thykier.net" in styles.maintainer_preferences
nt_style = styles.maintainer_preferences["niels@thykier.net"]
# Note this is data dependent; if it fails because the style changes, update the test
@@ -32,7 +32,7 @@ def test_load_styles() -> None:
def test_load_named_styles() -> None:
- styles = StylePreferenceTable.load_styles()
+ styles = MaintainerPreferenceTable.load_preferences()
assert "black" in styles.named_styles
black_style = styles.named_styles["black"]
# Note this is data dependent; if it fails because the style changes, update the test
@@ -48,7 +48,7 @@ def test_load_named_styles() -> None:
def test_compat_styles() -> None:
- styles = StylePreferenceTable.load_styles()
+ styles = MaintainerPreferenceTable.load_preferences()
# Data dependent; if it breaks, provide a stubbed style preference table
assert "niels@thykier.net" in styles.maintainer_preferences
@@ -71,30 +71,33 @@ def test_compat_styles() -> None:
)
src = SourcePackage(fields)
- effective_style, _ = determine_effective_style(styles, src, None)
+ effective_style, tool, _ = determine_effective_preference(styles, src, None)
assert effective_style == nt_pref
+ assert tool == "debputy reformat"
fields["Uploaders"] = (
"Niels Thykier <niels@thykier.net>, Chris Hofstaedtler <zeha@debian.org>"
)
src = SourcePackage(fields)
- effective_style, _ = determine_effective_style(styles, src, None)
+ effective_style, tool, _ = determine_effective_preference(styles, src, None)
assert effective_style == nt_pref
assert effective_style == zeha_pref
+ assert tool == "debputy reformat"
fields["Uploaders"] = (
"Niels Thykier <niels@thykier.net>, Chris Hofstaedtler <zeha@debian.org>, Random Developer <random@example.org>"
)
src = SourcePackage(fields)
- effective_style, _ = determine_effective_style(styles, src, None)
+ effective_style, tool, _ = determine_effective_preference(styles, src, None)
assert effective_style is None
+ assert tool is None
@pytest.mark.xfail
def test_compat_styles_team_maint() -> None:
- styles = StylePreferenceTable.load_styles()
+ styles = MaintainerPreferenceTable.load_preferences()
fields = Deb822(
{
"Package": "foo",
@@ -108,12 +111,13 @@ def test_compat_styles_team_maint() -> None:
assert "random@example.org" not in styles.maintainer_preferences
team_style = styles.maintainer_preferences["team@lists.debian.org"]
assert team_style.is_packaging_team
- effective_style, _ = determine_effective_style(styles, src, None)
+ effective_style, tool, _ = determine_effective_preference(styles, src, None)
assert effective_style == team_style.as_effective_pref()
+ assert tool is None
def test_x_style() -> None:
- styles = StylePreferenceTable.load_styles()
+ styles = MaintainerPreferenceTable.load_preferences()
fields = Deb822(
{
"Package": "foo",
@@ -125,12 +129,13 @@ def test_x_style() -> None:
assert "random@example.org" not in styles.maintainer_preferences
assert "black" in styles.named_styles
black_style = styles.named_styles["black"]
- effective_style, _ = determine_effective_style(styles, src, None)
+ effective_style, tool, _ = determine_effective_preference(styles, src, None)
assert effective_style == black_style
+ assert tool == "debputy reformat"
def test_was_from_salsa_ci_style() -> None:
- styles = StylePreferenceTable.load_styles()
+ styles = MaintainerPreferenceTable.load_preferences()
fields = Deb822(
{
"Package": "foo",
@@ -139,20 +144,23 @@ def test_was_from_salsa_ci_style() -> None:
)
src = SourcePackage(fields)
assert "random@example.org" not in styles.maintainer_preferences
- effective_style, _ = determine_effective_style(styles, src, None)
+ effective_style, tool, _ = determine_effective_preference(styles, src, None)
assert effective_style is None
+ assert tool is None
salsa_ci = CommentedMap(
{"variables": CommentedMap({"SALSA_CI_DISABLE_WRAP_AND_SORT": "yes"})}
)
- effective_style, _ = determine_effective_style(styles, src, salsa_ci)
+ effective_style, tool, _ = determine_effective_preference(styles, src, salsa_ci)
assert effective_style is None
+ assert tool is None
salsa_ci = CommentedMap(
{"variables": CommentedMap({"SALSA_CI_DISABLE_WRAP_AND_SORT": "no"})}
)
- effective_style, _ = determine_effective_style(styles, src, salsa_ci)
+ effective_style, tool, _ = determine_effective_preference(styles, src, salsa_ci)
was_style = EffectivePreference(**_WAS_DEFAULTS)
assert effective_style == was_style
+ assert tool == "wrap-and-sort"
@pytest.mark.parametrize(
@@ -197,9 +205,10 @@ def test_was_from_salsa_ci_style() -> None:
],
)
def test_was_from_salsa_ci_style_args(
- was_args: str, style_delta: Optional[Mapping[str, Any]]
+ was_args: str,
+ style_delta: Optional[Mapping[str, Any]],
) -> None:
- styles = StylePreferenceTable.load_styles()
+ styles = MaintainerPreferenceTable.load_preferences()
fields = Deb822(
{
"Package": "foo",
@@ -218,12 +227,14 @@ def test_was_from_salsa_ci_style_args(
)
}
)
- effective_style, _ = determine_effective_style(styles, src, salsa_ci)
+ effective_style, tool, _ = determine_effective_preference(styles, src, salsa_ci)
if style_delta is None:
assert effective_style is None
+ assert tool is None
else:
was_style = EffectivePreference(**_WAS_DEFAULTS).replace(
**style_delta,
)
assert effective_style == was_style
+ assert tool == f"wrap-and-sort {was_args}".strip()