mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Use patch.object to temporarily replace mock a function call
CURA-7319
This commit is contained in:
parent
d5b58cf3b4
commit
dec68002bc
1 changed files with 6 additions and 7 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue