From 4dad612447c4ee4b1ae84a7e959fd5d2e5b40588 Mon Sep 17 00:00:00 2001 From: Vishal Shah Date: Sat, 15 Jun 2024 18:01:16 -0400 Subject: [PATCH 1/2] Added support for SkipHandlers --- cumulusci/salesforce_api/package_install.py | 9 +++++++ .../tests/test_package_install.py | 24 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/cumulusci/salesforce_api/package_install.py b/cumulusci/salesforce_api/package_install.py index c5c5162272..64fd9bb141 100644 --- a/cumulusci/salesforce_api/package_install.py +++ b/cumulusci/salesforce_api/package_install.py @@ -52,6 +52,8 @@ class UpgradeType(StrEnum): DEPRECATE_ONLY = "deprecate-only" MIXED = "mixed" +class SkipHandlers(StrEnum): + FEATURE_ENFORCEMENT = "FeatureEnforcement" class PackageInstallOptions(CCIModel): """Options governing installation behavior for a managed or unlocked package.""" @@ -62,6 +64,7 @@ class PackageInstallOptions(CCIModel): security_type: SecurityType = SecurityType.FULL apex_compile_type: Optional[ApexCompileType] = None upgrade_type: Optional[UpgradeType] = None + skip_handlers: SkipHandlers = SkipHandlers.FEATURE_ENFORCEMENT @staticmethod def from_task_options(task_options: dict) -> "PackageInstallOptions": @@ -86,6 +89,8 @@ def from_task_options(task_options: dict) -> "PackageInstallOptions": ) if "upgrade_type" in task_options: options.upgrade_type = UpgradeType(task_options["upgrade_type"]) + if "skip_handlers" in task_options: + options.skip_handlers = SkipHandlers(task_options["skip_handlers"]) except ValueError as e: raise TaskOptionsError(f"Invalid task options: {e}") @@ -111,6 +116,9 @@ def from_task_options(task_options: dict) -> "PackageInstallOptions": "upgrade_type": { "description": "For Unlocked Package upgrades only, whether to deprecate removed components (`deprecate-only`), delete them (`delete-only`), or delete and deprecate based on safety (`mixed`). `mixed` is the default behavior." }, + "skip_handlers": { + "description": "Specifies the handlers that are skipped when the package is installed. There's only one valid value:`FeatureEnforcement`: For package installs in scratch orgs only. Available in API version 61.0 and later." + }, } DEFAULT_PACKAGE_RETRY_OPTIONS = { @@ -171,6 +179,7 @@ def _install_package_by_version_id( "SubscriberPackageVersionKey": version_id, "UpgradeType": options.upgrade_type, "ApexCompileType": options.apex_compile_type, + "SkipHandlers": options.skip_handlers, } ) poll(functools.partial(_wait_for_package_install, tooling, request)) diff --git a/cumulusci/salesforce_api/tests/test_package_install.py b/cumulusci/salesforce_api/tests/test_package_install.py index b568feb498..c47f78324e 100644 --- a/cumulusci/salesforce_api/tests/test_package_install.py +++ b/cumulusci/salesforce_api/tests/test_package_install.py @@ -15,6 +15,7 @@ PackageInstallOptions, SecurityType, UpgradeType, + SkipHandlers, install_package_by_namespace_version, install_package_by_version_id, ) @@ -217,3 +218,26 @@ def test_package_install_options_from_task_options__omitting_optionals(): apex_compile_type=ApexCompileType.PACKAGE, upgrade_type=UpgradeType.DEPRECATE_ONLY, ) + +def test_package_install_options_from_task_options__with_skip_handlers(): + task_options = { + "activate_remote_site_settings": "False", + "name_conflict_resolution": "RenameMetadata", + "password": "foo", + "security_type": "PUSH", + "apex_compile_type": "package", + "upgrade_type": "deprecate-only", + "skip_handlers": "FeatureEnforcement", + } + + assert PackageInstallOptions.from_task_options( + task_options + ) == PackageInstallOptions( + activate_remote_site_settings=False, + name_conflict_resolution=NameConflictResolution.RENAME, + password="foo", + security_type=SecurityType.PUSH, + apex_compile_type=ApexCompileType.PACKAGE, + upgrade_type=UpgradeType.DEPRECATE_ONLY, + skip_handlers=SkipHandlers.FEATURE_ENFORCEMENT, + ) From 20b567a2c74baef9c825275a5552b7925fbc96d1 Mon Sep 17 00:00:00 2001 From: Vishal Shah Date: Sat, 22 Jun 2024 00:27:32 -0400 Subject: [PATCH 2/2] Defaulted the SkipHandlers option to None --- cumulusci/salesforce_api/package_install.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cumulusci/salesforce_api/package_install.py b/cumulusci/salesforce_api/package_install.py index 64fd9bb141..c3f41b12ae 100644 --- a/cumulusci/salesforce_api/package_install.py +++ b/cumulusci/salesforce_api/package_install.py @@ -64,7 +64,7 @@ class PackageInstallOptions(CCIModel): security_type: SecurityType = SecurityType.FULL apex_compile_type: Optional[ApexCompileType] = None upgrade_type: Optional[UpgradeType] = None - skip_handlers: SkipHandlers = SkipHandlers.FEATURE_ENFORCEMENT + skip_handlers: SkipHandlers = None @staticmethod def from_task_options(task_options: dict) -> "PackageInstallOptions": @@ -90,7 +90,7 @@ def from_task_options(task_options: dict) -> "PackageInstallOptions": if "upgrade_type" in task_options: options.upgrade_type = UpgradeType(task_options["upgrade_type"]) if "skip_handlers" in task_options: - options.skip_handlers = SkipHandlers(task_options["skip_handlers"]) + options.skip_handlers = SkipHandlers(task_options["skip_handlers"]) # allow for multiple values in the futute. except ValueError as e: raise TaskOptionsError(f"Invalid task options: {e}")