mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add test for license reading with dpkg_lowpkg
This commit is contained in:
parent
5dbd7dd7e8
commit
e1a132dce8
1 changed files with 18 additions and 0 deletions
18
tests/pytests/unit/modules/test_dpkg_lowpkg.py
Normal file
18
tests/pytests/unit/modules/test_dpkg_lowpkg.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import os
|
||||
|
||||
import salt.modules.dpkg_lowpkg as dpkg
|
||||
from tests.support.mock import MagicMock, mock_open, patch
|
||||
|
||||
|
||||
def test_get_pkg_license():
|
||||
"""
|
||||
Test _get_pkg_license for ignore errors on reading license from copyright files
|
||||
"""
|
||||
license_read_mock = mock_open(read_data="")
|
||||
with patch.object(os.path, "exists", MagicMock(return_value=True)), patch(
|
||||
"salt.utils.files.fopen", license_read_mock
|
||||
):
|
||||
dpkg._get_pkg_license("bash")
|
||||
|
||||
assert license_read_mock.calls[0].args[0] == "/usr/share/doc/bash/copyright"
|
||||
assert license_read_mock.calls[0].kwargs["errors"] == "ignore"
|
Loading…
Add table
Reference in a new issue