This commit is contained in:
Yousefnezhad 2025-06-16 09:25:10 +03:30
commit 07c0ac9390

View file

@ -14,7 +14,7 @@ except ImportError:
import pytest
import sys
import os
import hashlib
import hashlib
sys.path.insert(0, os.path.abspath(
@ -36,14 +36,14 @@ def fake_exports_content():
def calculate_expected_digests(content_string):
content_bytes = content_string.encode('utf-8')
digests = {}
hash_algorithms = ['sha256', 'sha1', 'md5']
hash_algorithms = ['sha256', 'sha1', 'md5']
for algo in hash_algorithms:
try:
hasher = hashlib.new(algo)
hasher.update(content_bytes)
digests[algo] = hasher.hexdigest()
except ValueError:
pass
pass
return digests
@ -51,9 +51,7 @@ def test_get_exports_ips_per_share(fake_exports_content):
mock_module = MagicMock()
mock_module.file_exists.return_value = True
mock_module.warn.return_value = None
mock_module.fail_json.side_effect = Exception("fail_json called")
mock_module.fail_json.side_effect = Exception("fail_json called")
patch_target = "builtins.open" if sys.version_info[0] == 3 else "__builtin__.open"
with patch(patch_target, mock_open(read_data=fake_exports_content.encode('utf-8'))):
@ -77,14 +75,9 @@ def test_get_exports_ips_per_share(fake_exports_content):
def test_get_exports_shares_per_ip(fake_exports_content):
mock_module = MagicMock()
mock_module.file_exists.return_value = True
mock_module.warn.return_value = None
mock_module.fail_json.side_effect = Exception("fail_json called")
patch_target = "builtins.open" if sys.version_info[0] == 3 else "__builtin__.open"
with patch(patch_target, mock_open(read_data=fake_exports_content.encode('utf-8'))):