diff --git a/plugins/PostProcessingPlugin/tests/TestPostProcessingPlugin.py b/plugins/PostProcessingPlugin/tests/TestPostProcessingPlugin.py index a5ef9e47c9..2c9a25fcac 100644 --- a/plugins/PostProcessingPlugin/tests/TestPostProcessingPlugin.py +++ b/plugins/PostProcessingPlugin/tests/TestPostProcessingPlugin.py @@ -18,30 +18,29 @@ sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) def test_community_user_script_allowed(): assert PostProcessingPlugin._isScriptAllowed("blaat.py") + # noinspection PyProtectedMember @patch("cura.ApplicationMetadata.IsEnterpriseVersion", False) def test_community_bundled_script_allowed(): assert PostProcessingPlugin._isScriptAllowed(_bundled_file_path()) + # noinspection PyProtectedMember @patch("cura.ApplicationMetadata.IsEnterpriseVersion", True) def test_enterprise_unsigned_user_script_not_allowed(): assert not PostProcessingPlugin._isScriptAllowed("blaat.py") + # noinspection PyProtectedMember @patch("cura.ApplicationMetadata.IsEnterpriseVersion", True) def test_enterprise_signed_user_script_allowed(): mocked_trust = MagicMock() mocked_trust.signedFileCheck = MagicMock(return_value=True) - realSignatureFileExistsFor = Trust.signatureFileExistsFor - Trust.signatureFileExistsFor = MagicMock(return_value=True) + with patch.object(Trust, "signatureFileExistsFor", return_value = True): + with patch("UM.Trust.Trust.getInstanceOrNone", return_value=mocked_trust): + assert PostProcessingPlugin._isScriptAllowed("blaat.py") - with patch("UM.Trust.Trust.getInstanceOrNone", return_value=mocked_trust): - assert PostProcessingPlugin._isScriptAllowed("blaat.py") - - # cleanup - Trust.signatureFileExistsFor = realSignatureFileExistsFor # noinspection PyProtectedMember @patch("cura.ApplicationMetadata.IsEnterpriseVersion", False)