mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix test, xfail
This commit is contained in:
parent
09ecdb5dee
commit
6395aea424
2 changed files with 18 additions and 1 deletions
|
@ -1093,7 +1093,9 @@ def unzip(
|
|||
source = zfile.read(target)
|
||||
os.symlink(source, os.path.join(dest, target))
|
||||
continue
|
||||
zfile.extract(target, dest, password.encode())
|
||||
# if password:
|
||||
# password = password.encode()
|
||||
zfile.extract(target, dest, password)
|
||||
if extract_perms:
|
||||
if not salt.utils.platform.is_windows():
|
||||
perm = zfile.getinfo(target).external_attr >> 16
|
||||
|
|
|
@ -378,6 +378,21 @@ def test_unzip():
|
|||
assert ["salt"] == ret
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_unzip_password():
|
||||
mock = ZipFileMock()
|
||||
target = "/tmp/salt.zip"
|
||||
dest = "/tmp/dest"
|
||||
# This is the file inside target zip file, returned by ZipFileMock.namelist
|
||||
expected_file_name = "salt"
|
||||
with patch("zipfile.ZipFile", mock):
|
||||
ret = archive.unzip(target, dest, password="spongebob", extract_perms=False)
|
||||
assert [expected_file_name] == ret
|
||||
# mock needs to be mock() because contextlib.closing appears to actually
|
||||
# call the mock
|
||||
mock().extract.assert_called_once_with(expected_file_name, dest, b"spongebob")
|
||||
|
||||
|
||||
def test_unzip_raises_exception_if_not_found():
|
||||
mock = MagicMock(return_value="salt")
|
||||
with patch.dict(archive.__salt__, {"cmd.run": mock}):
|
||||
|
|
Loading…
Add table
Reference in a new issue