"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/unit/modules/test_win_wua.py" between
salt-3002.1.tar.gz and salt-3002.2.tar.gz

About: SaltStack is a systems management software for data center automation, cloud orchestration, server provisioning, configuration management and more. Community version.

test_win_wua.py  (salt-3002.1):test_win_wua.py  (salt-3002.2)
skipping to change at line 41 skipping to change at line 41
return UPDATES_SUMMARY return UPDATES_SUMMARY
@skipIf(not salt.utils.platform.is_windows(), "System is not Windows") @skipIf(not salt.utils.platform.is_windows(), "System is not Windows")
class WinWuaInstalledTestCase(TestCase): class WinWuaInstalledTestCase(TestCase):
""" """
Test the functions in the win_wua.installed function Test the functions in the win_wua.installed function
""" """
service_auto = {"StartType": "Auto"} service_auto = {"StartType": "Auto"}
service_disabled = {"StartType": "Disabled"} service_disabled = {"StartType": "Disabled"}
service_manual = {"StartType": "Manual"}
def test__virtual__not_windows(self): def test__virtual__not_windows(self):
""" """
Test __virtual__ function on Non-Windows Test __virtual__ function on Non-Windows
""" """
with patch("salt.utils.platform.is_windows", autospec=True, return_value =False): with patch("salt.utils.platform.is_windows", autospec=True, return_value =False):
expected = (False, "WUA: Only available on Windows systems") expected = (False, "WUA: Only available on Windows systems")
result = win_wua.__virtual__() result = win_wua.__virtual__()
self.assertEqual(expected, result) self.assertEqual(expected, result)
skipping to change at line 64 skipping to change at line 65
""" """
with patch("salt.modules.win_wua.HAS_PYWIN32", False): with patch("salt.modules.win_wua.HAS_PYWIN32", False):
expected = (False, "WUA: Requires PyWin32 libraries") expected = (False, "WUA: Requires PyWin32 libraries")
result = win_wua.__virtual__() result = win_wua.__virtual__()
self.assertEqual(expected, result) self.assertEqual(expected, result)
def test__virtual__wuauserv_disabled(self): def test__virtual__wuauserv_disabled(self):
""" """
Test __virtual__ function when the wuauserv service is disabled Test __virtual__ function when the wuauserv service is disabled
""" """
disabled_wuauserv = MagicMock( mock_service_info = MagicMock(
side_effect=[ side_effect=[
self.service_disabled, # wuauserv self.service_disabled, # wuauserv
self.service_auto, # msiserver self.service_auto, # msiserver
self.service_auto, # BITS self.service_auto, # BITS
self.service_auto, # CryptSvc self.service_auto, # CryptSvc
self.service_auto, # TrustedInstaller self.service_auto, # TrustedInstaller
] ]
) )
with patch("salt.utils.win_service.info", disabled_wuauserv): with patch("salt.utils.win_service.info", mock_service_info):
expected = ( expected = (
False, False,
"WUA: The Windows Update service (wuauserv) must not be disabled ", "WUA: The Windows Update service (wuauserv) must not be disabled ",
) )
result = win_wua.__virtual__() result = win_wua.__virtual__()
self.assertEqual(expected, result) self.assertEqual(expected, result)
def test__virtual__msiserver_disabled(self): def test__virtual__msiserver_disabled(self):
""" """
Test __virtual__ function when the msiserver service is disabled Test __virtual__ function when the msiserver service is disabled
""" """
disabled_wuauserv = MagicMock( mock_service_info = MagicMock(
side_effect=[ side_effect=[
self.service_auto, # wuauserv self.service_auto, # wuauserv
self.service_disabled, # msiserver self.service_disabled, # msiserver
self.service_auto, # BITS self.service_auto, # BITS
self.service_auto, # CryptSvc self.service_auto, # CryptSvc
self.service_auto, # TrustedInstaller self.service_auto, # TrustedInstaller
] ]
) )
with patch("salt.utils.win_service.info", disabled_wuauserv): with patch("salt.utils.win_service.info", mock_service_info):
expected = ( expected = (
False, False,
"WUA: The Windows Installer service (msiserver) must not be disa bled", "WUA: The Windows Installer service (msiserver) must not be disa bled",
) )
result = win_wua.__virtual__() result = win_wua.__virtual__()
self.assertEqual(expected, result) self.assertEqual(expected, result)
def test__virtual__BITS_disabled(self): def test__virtual__BITS_disabled(self):
""" """
Test __virtual__ function when the BITS service is disabled Test __virtual__ function when the BITS service is disabled
""" """
disabled_wuauserv = MagicMock( mock_service_info = MagicMock(
side_effect=[ side_effect=[
self.service_auto, # wuauserv self.service_auto, # wuauserv
self.service_auto, # msiserver self.service_auto, # msiserver
self.service_disabled, # BITS self.service_disabled, # BITS
self.service_auto, # CryptSvc self.service_auto, # CryptSvc
self.service_auto, # TrustedInstaller self.service_auto, # TrustedInstaller
] ]
) )
with patch("salt.utils.win_service.info", disabled_wuauserv): with patch("salt.utils.win_service.info", mock_service_info):
expected = ( expected = (
False, False,
"WUA: The Background Intelligent Transfer service (bits) must no t be disabled", "WUA: The Background Intelligent Transfer service (bits) must no t be disabled",
) )
result = win_wua.__virtual__() result = win_wua.__virtual__()
self.assertEqual(expected, result) self.assertEqual(expected, result)
def test__virtual__BITS_manual(self):
"""
Test __virtual__ function when the BITS service is set to manual
Should not disable the module (__virtual__ should return True)
"""
mock_service_info = MagicMock(
side_effect=[
self.service_auto, # wuauserv
self.service_auto, # msiserver
self.service_manual, # BITS
self.service_auto, # CryptSvc
self.service_auto, # TrustedInstaller
]
)
with patch("salt.utils.win_service.info", mock_service_info):
expected = True
result = win_wua.__virtual__()
self.assertEqual(expected, result)
def test__virtual__CryptSvc_disabled(self): def test__virtual__CryptSvc_disabled(self):
""" """
Test __virtual__ function when the CryptSvc service is disabled Test __virtual__ function when the CryptSvc service is disabled
""" """
disabled_wuauserv = MagicMock( mock_service_info = MagicMock(
side_effect=[ side_effect=[
self.service_auto, # wuauserv self.service_auto, # wuauserv
self.service_auto, # msiserver self.service_auto, # msiserver
self.service_auto, # BITS self.service_auto, # BITS
self.service_disabled, # CryptSvc self.service_disabled, # CryptSvc
self.service_auto, # TrustedInstaller self.service_auto, # TrustedInstaller
] ]
) )
with patch("salt.utils.win_service.info", disabled_wuauserv): with patch("salt.utils.win_service.info", mock_service_info):
expected = ( expected = (
False, False,
"WUA: The Cryptographic Services service (CryptSvc) must not be disabled", "WUA: The Cryptographic Services service (CryptSvc) must not be disabled",
) )
result = win_wua.__virtual__() result = win_wua.__virtual__()
self.assertEqual(expected, result) self.assertEqual(expected, result)
def test__virtual__TrustedInstaller_disabled(self): def test__virtual__TrustedInstaller_disabled(self):
""" """
Test __virtual__ function when the TrustedInstaller service is disabled Test __virtual__ function when the TrustedInstaller service is disabled
""" """
disabled_wuauserv = MagicMock( mock_service_info = MagicMock(
side_effect=[ side_effect=[
self.service_auto, # wuauserv self.service_auto, # wuauserv
self.service_auto, # msiserver self.service_auto, # msiserver
self.service_auto, # BITS self.service_auto, # BITS
self.service_auto, # CryptSvc self.service_auto, # CryptSvc
self.service_disabled, # TrustedInstaller self.service_disabled, # TrustedInstaller
] ]
) )
with patch("salt.utils.win_service.info", disabled_wuauserv): with patch("salt.utils.win_service.info", mock_service_info):
expected = ( expected = (
False, False,
"WUA: The Windows Module Installer service (TrustedInstaller) mu st not be disabled", "WUA: The Windows Module Installer service (TrustedInstaller) mu st not be disabled",
) )
result = win_wua.__virtual__() result = win_wua.__virtual__()
self.assertEqual(expected, result) self.assertEqual(expected, result)
def test_installed(self): def test_installed(self):
""" """
Test installed function default Test installed function default
 End of changes. 12 change blocks. 
10 lines changed or deleted 30 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)