From a3eb4d225202a945e3271aa1d69fae262ddfff69 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Thu, 15 Aug 2024 00:54:09 -0500 Subject: [PATCH] nfpm: fmt --- .../nfpm/util_rules/generate_config_test.py | 59 +++++++++++-- .../backend/nfpm/util_rules/sandbox_test.py | 82 +++++++++++++++---- 2 files changed, 119 insertions(+), 22 deletions(-) diff --git a/src/python/pants/backend/nfpm/util_rules/generate_config_test.py b/src/python/pants/backend/nfpm/util_rules/generate_config_test.py index 848b014401e..1ab29ba8912 100644 --- a/src/python/pants/backend/nfpm/util_rules/generate_config_test.py +++ b/src/python/pants/backend/nfpm/util_rules/generate_config_test.py @@ -84,15 +84,62 @@ def get_digest(rule_runner: RuleRunner, source_files: dict[str, str]) -> Digest: ( # no dependencies pytest.param("apk", NfpmApkPackageFieldSet, [], {}, [], {}, None, id="apk-no-deps"), - pytest.param("archlinux", NfpmArchlinuxPackageFieldSet, [], {}, [], {}, None, id="archlinux-no-deps"), + pytest.param( + "archlinux", NfpmArchlinuxPackageFieldSet, [], {}, [], {}, None, id="archlinux-no-deps" + ), pytest.param("deb", NfpmDebPackageFieldSet, [], {}, [], {}, None, id="deb-no-deps"), pytest.param("rpm", NfpmRpmPackageFieldSet, [], {}, [], {}, None, id="rpm-no-deps"), - pytest.param("rpm", NfpmRpmPackageFieldSet, [], {}, [], {"ghost_contents": ["/var/log/pkg.log"]}, None, id="rpm-no-deps-with-ghost"), + pytest.param( + "rpm", + NfpmRpmPackageFieldSet, + [], + {}, + [], + {"ghost_contents": ["/var/log/pkg.log"]}, + None, + id="rpm-no-deps-with-ghost", + ), # no dependencies (extra file does not cause errors) - pytest.param("apk", NfpmApkPackageFieldSet, [], {}, ["contents/extra-file.txt"], {}, None, id="apk-no-deps-with-extra-file"), - pytest.param("archlinux", NfpmArchlinuxPackageFieldSet, [], {}, ["contents/extra-file.txt"], {}, None, id="archlinux-no-deps-with-extra-file"), - pytest.param("deb", NfpmDebPackageFieldSet, [], {}, ["contents/extra-file.txt"], {}, None, id="deb-no-deps-with-extra-file"), - pytest.param("rpm", NfpmRpmPackageFieldSet, [], {}, ["contents/extra-file.txt"], {}, None, id="rpm-no-deps-with-extra-file"), + pytest.param( + "apk", + NfpmApkPackageFieldSet, + [], + {}, + ["contents/extra-file.txt"], + {}, + None, + id="apk-no-deps-with-extra-file", + ), + pytest.param( + "archlinux", + NfpmArchlinuxPackageFieldSet, + [], + {}, + ["contents/extra-file.txt"], + {}, + None, + id="archlinux-no-deps-with-extra-file", + ), + pytest.param( + "deb", + NfpmDebPackageFieldSet, + [], + {}, + ["contents/extra-file.txt"], + {}, + None, + id="deb-no-deps-with-extra-file", + ), + pytest.param( + "rpm", + NfpmRpmPackageFieldSet, + [], + {}, + ["contents/extra-file.txt"], + {}, + None, + id="rpm-no-deps-with-extra-file", + ), pytest.param( "rpm", NfpmRpmPackageFieldSet, diff --git a/src/python/pants/backend/nfpm/util_rules/sandbox_test.py b/src/python/pants/backend/nfpm/util_rules/sandbox_test.py index 54d7f45701c..c30e71f7f3f 100644 --- a/src/python/pants/backend/nfpm/util_rules/sandbox_test.py +++ b/src/python/pants/backend/nfpm/util_rules/sandbox_test.py @@ -72,7 +72,12 @@ @pytest.mark.parametrize( "tgt,field_set_type,expected", ( - pytest.param(NfpmContentDir({"dst": "/foo"}, _A), NfpmPackageFieldSet, _DepCategory.ignore, id="content_dir"), + pytest.param( + NfpmContentDir({"dst": "/foo"}, _A), + NfpmPackageFieldSet, + _DepCategory.ignore, + id="content_dir", + ), pytest.param( NfpmContentSymlink({"dst": "/foo", "src": "/bar"}, _A), NfpmPackageFieldSet, # does not matter @@ -91,26 +96,69 @@ _DepCategory.nfpm_content_from_source, id="content_file-from-source", ), - pytest.param(_APK_PKG, NfpmApkPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-apk-apk"), - pytest.param(_APK_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.ignore, id="pkgs-apk-archlinux"), + pytest.param( + _APK_PKG, NfpmApkPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-apk-apk" + ), + pytest.param( + _APK_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.ignore, id="pkgs-apk-archlinux" + ), pytest.param(_APK_PKG, NfpmDebPackageFieldSet, _DepCategory.ignore, id="pkgs-apk-deb"), pytest.param(_APK_PKG, NfpmRpmPackageFieldSet, _DepCategory.ignore, id="pkgs-apk-rpm"), - pytest.param(_ARCHLINUX_PKG, NfpmApkPackageFieldSet, _DepCategory.ignore, id="pkgs-archlinux-apk"), - pytest.param(_ARCHLINUX_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-archlinux-archlinux"), - pytest.param(_ARCHLINUX_PKG, NfpmDebPackageFieldSet, _DepCategory.ignore, id="pkgs-archlinux-deb"), - pytest.param(_ARCHLINUX_PKG, NfpmRpmPackageFieldSet, _DepCategory.ignore, id="pkgs-archlinux-rpm"), + pytest.param( + _ARCHLINUX_PKG, NfpmApkPackageFieldSet, _DepCategory.ignore, id="pkgs-archlinux-apk" + ), + pytest.param( + _ARCHLINUX_PKG, + NfpmArchlinuxPackageFieldSet, + _DepCategory.nfpm_package, + id="pkgs-archlinux-archlinux", + ), + pytest.param( + _ARCHLINUX_PKG, NfpmDebPackageFieldSet, _DepCategory.ignore, id="pkgs-archlinux-deb" + ), + pytest.param( + _ARCHLINUX_PKG, NfpmRpmPackageFieldSet, _DepCategory.ignore, id="pkgs-archlinux-rpm" + ), pytest.param(_DEB_PKG, NfpmApkPackageFieldSet, _DepCategory.ignore, id="pkgs-deb-apk"), - pytest.param(_DEB_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.ignore, id="pkgs-deb-archlinux"), - pytest.param(_DEB_PKG, NfpmDebPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-deb-deb"), + pytest.param( + _DEB_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.ignore, id="pkgs-deb-archlinux" + ), + pytest.param( + _DEB_PKG, NfpmDebPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-deb-deb" + ), pytest.param(_DEB_PKG, NfpmRpmPackageFieldSet, _DepCategory.ignore, id="pkgs-deb-rpm"), pytest.param(_RPM_PKG, NfpmApkPackageFieldSet, _DepCategory.ignore, id="pkgs-rpm-apk"), - pytest.param(_RPM_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.ignore, id="pkgs-rpm-archlinux"), + pytest.param( + _RPM_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.ignore, id="pkgs-rpm-archlinux" + ), pytest.param(_RPM_PKG, NfpmDebPackageFieldSet, _DepCategory.ignore, id="pkgs-rpm-deb"), - pytest.param(_RPM_PKG, NfpmRpmPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-rpm-rpm"), - pytest.param(GenericTarget({}, _A), NfpmPackageFieldSet, _DepCategory.remaining, id="generic_target"), - pytest.param(FileTarget({"source": "foo"}, _A), NfpmPackageFieldSet, _DepCategory.remaining, id="file"), - pytest.param(ResourceTarget({"source": "foo"}, _A), NfpmPackageFieldSet, _DepCategory.remaining, id="resource"), - pytest.param(ArchiveTarget({"format": "zip"}, _A), NfpmPackageFieldSet, _DepCategory.remaining, id="archive"), + pytest.param( + _RPM_PKG, NfpmRpmPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-rpm-rpm" + ), + pytest.param( + GenericTarget({}, _A), + NfpmPackageFieldSet, + _DepCategory.remaining, + id="generic_target", + ), + pytest.param( + FileTarget({"source": "foo"}, _A), + NfpmPackageFieldSet, + _DepCategory.remaining, + id="file", + ), + pytest.param( + ResourceTarget({"source": "foo"}, _A), + NfpmPackageFieldSet, + _DepCategory.remaining, + id="resource", + ), + pytest.param( + ArchiveTarget({"format": "zip"}, _A), + NfpmPackageFieldSet, + _DepCategory.remaining, + id="archive", + ), ), ) def test_dep_category_for_target( @@ -182,7 +230,9 @@ def rule_runner() -> RuleRunner: ( # empty digest pytest.param("apk", NfpmApkPackageFieldSet, [], {}, set(), id="apk-empty-digest"), - pytest.param("archlinux", NfpmArchlinuxPackageFieldSet, [], {}, set(), id="archlinux-empty-digest"), + pytest.param( + "archlinux", NfpmArchlinuxPackageFieldSet, [], {}, set(), id="archlinux-empty-digest" + ), pytest.param("deb", NfpmDebPackageFieldSet, [], {}, set(), id="deb-empty-digest"), pytest.param("rpm", NfpmRpmPackageFieldSet, [], {}, set(), id="rpm-empty-digest"), # non-empty digest